Repetier-Firmware  1.0.0
u8glib_ex.h
Go to the documentation of this file.
1 /*
2 
3  U8glib.cpp
4 
5  C++ Interface
6 
7  Universal 8bit Graphics Library
8 
9  Copyright (c) 2011, olikraus@gmail.com
10  All rights reserved.
11 
12  Redistribution and use in source and binary forms, with or without modification,
13  are permitted provided that the following conditions are met:
14 
15  * Redistributions of source code must retain the above copyright notice, this list
16  of conditions and the following disclaimer.
17 
18  * Redistributions in binary form must reproduce the above copyright notice, this
19  list of conditions and the following disclaimer in the documentation and/or other
20  materials provided with the distribution.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36 
37 The U8glib code (http://code.google.com/p/u8glib/) is licensed under the terms of
38 the new-bsd license (two-clause bsd license).
39 See also: http://www.opensource.org/licenses/bsd-license.php
40 
41 The repository and optionally the releases contain icons, which are
42 derived from the WPZOOM Developer Icon Set:
43 http://www.wpzoom.com/wpzoom/new-freebie-wpzoom-developer-icon-set-154-free-icons/
44 WPZOOM Developer Icon Set by WPZOOM is licensed under a Creative Commons
45 Attribution-ShareAlike 3.0 Unported License.
46 
47 Fonts are licensed under different conditions.
48 See http://code.google.com/p/u8glib/wiki/fontgroup for
49 detailed information on the licensing conditions for each font.
50 
51 ============ X11 Fonts COUR, HELV, NCEN, TIM, SYMB ============
52 
53 For fonts derived from the following files, the license below applies.
54 COURB08.BDF COURB10.BDF COURB12.BDF COURB14.BDF COURB18.BDF
55 COURB24.BDF COURR08.BDF COURR10.BDF COURR12.BDF COURR14.BDF
56 COURR18.BDF COURR24.BDF HELVB08.BDF HELVB10.BDF HELVB12.BDF HELVB14.BDF
57 HELVB18.BDF HELVB24.BDF HELVR08.BDF HELVR10.BDF HELVR12.BDF HELVR14.BDF
58 HELVR18.BDF HELVR24.BDF NCENB08.BDF NCENB10.BDF NCENB12.BDF
59 NCENB14.BDF NCENB18.BDF NCENB24.BDF NCENR08.BDF NCENR10.BDF
60 NCENR12.BDF NCENR14.BDF NCENR18.BDF NCENR24.BDF SYMB08.BDF SYMB10.BDF
61 SYMB12.BDF SYMB14.BDF SYMB18.BDF SYMB24.BDF TIMB08.BDF TIMB10.BDF
62 TIMB12.BDF TIMB14.BDF TIMB18.BDF TIMB24.BDF TIMR08.BDF TIMR10.BDF
63 TIMR12.BDF TIMR14.BDF TIMR18.BDF TIMR24.BDF
64 
65 Copyright 1984-1989, 1994 Adobe Systems Incorporated.
66 Copyright 1988, 1994 Digital Equipment Corporation.
67 
68 Adobe is a trademark of Adobe Systems Incorporated which may be
69 registered in certain jurisdictions.
70 Permission to use these trademarks is hereby granted only in
71 association with the images described in this file.
72 
73 Permission to use, copy, modify, distribute and sell this software
74 and its documentation for any purpose and without fee is hereby
75 granted, provided that the above copyright notices appear in all
76 copies and that both those copyright notices and this permission
77 notice appear in supporting documentation, and that the names of
78 Adobe Systems and Digital Equipment Corporation not be used in
79 advertising or publicity pertaining to distribution of the software
80 without specific, written prior permission. Adobe Systems and
81 Digital Equipment Corporation make no representations about the
82 suitability of this software for any purpose. It is provided "as
83 is" without express or implied warranty.
84 
85 
86 ============ BSD License for U8glib Code ============
87 
88 Universal 8bit Graphics Library (http://code.google.com/p/u8glib/)
89 
90 Copyright (c) 2011, olikraus@gmail.com
91 All rights reserved.
92 
93 Redistribution and use in source and binary forms, with or without modification,
94 are permitted provided that the following conditions are met:
95 
96 * Redistributions of source code must retain the above copyright notice, this list
97  of conditions and the following disclaimer.
98 
99 * Redistributions in binary form must reproduce the above copyright notice, this
100  list of conditions and the following disclaimer in the documentation and/or other
101  materials provided with the distribution.
102 
103 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
104 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
105 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
106 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
107 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
108 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
109 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
110 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
111 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
112 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
113 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
114 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
115 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116 
117 */
118 
119 // these warnings appear and are no problem.
120 #pragma GCC diagnostic push
121 #pragma GCC diagnostic ignored "-Wunused-variable"
122 #pragma GCC diagnostic ignored "-Wunused-parameter"
123 
124 // ============= u8g.h ====================
125 
126 /*
127 
128  u8g.h
129 
130  Universal 8bit Graphics Library
131 
132  Copyright (c) 2011, olikraus@gmail.com
133  All rights reserved.
134 
135  Redistribution and use in source and binary forms, with or without modification,
136  are permitted provided that the following conditions are met:
137 
138  * Redistributions of source code must retain the above copyright notice, this list
139  of conditions and the following disclaimer.
140 
141  * Redistributions in binary form must reproduce the above copyright notice, this
142  list of conditions and the following disclaimer in the documentation and/or other
143  materials provided with the distribution.
144 
145  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
146  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
147  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
148  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
149  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
150  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
151  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
152  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
153  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
154  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
155  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
156  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
157  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
158 
159 */
160 
161 #ifndef _U8G_H
162 #define _U8G_H
163 
164 
165 /* uncomment the following line to support displays larger than 240x240 */
166 //#define U8G_16BIT 1
167 
168 /* comment the following line to generate more compact but interrupt unsafe code */
169 #define U8G_INTERRUPT_SAFE 1
170 
171 
172 #include <stddef.h>
173 
174 #ifdef __18CXX
175 typedef unsigned char uint8_t;
176 typedef signed char int8_t;
177 typedef unsigned short uint16_t;
178 typedef signed short int16_t;
179 #else
180 #include <stdint.h>
181 #endif
182 
183 #if defined(__AVR__)
184 #include <avr/pgmspace.h>
185 #endif
186 
187 /*
188  use the com interface directly on any systems which are not AVR or ARDUINO
189 */
190 #if defined(__AVR__) || defined(ARDUINO)
191 #define U8G_WITH_PINLIST
192 #endif
193 
194 
195 #ifdef __cplusplus
196 extern "C" {
197 #endif
198 
199 
200 /*===============================================================*/
201 #ifdef __GNUC__
202 # define U8G_NOINLINE __attribute__((noinline))
203 # define U8G_PURE __attribute__ ((pure))
204 # define U8G_NOCOMMON __attribute__ ((nocommon))
205 # define U8G_SECTION(name) __attribute__ ((section (name)))
206 # if defined(__MSPGCC__)
207 /* mspgcc does not have .progmem sections. Use -fdata-sections. */
208 # define U8G_FONT_SECTION(name)
209 # endif
210 # if defined(__AVR__)
211 # define U8G_FONT_SECTION(name) U8G_SECTION(".progmem." name)
212 # endif
213 #else
214 # define U8G_NOINLINE
215 # define U8G_PURE
216 # define U8G_NOCOMMON
217 # define U8G_SECTION(name)
218 #endif
219 
220 #ifndef U8G_FONT_SECTION
221 # define U8G_FONT_SECTION(name)
222 #endif
223 
224 
225 /*===============================================================*/
226 /* flash memory access */
227 
228 #if defined(__AVR__)
229 /* U8G_PROGMEM is used by the XBM example */
230 #define U8G_PROGMEM U8G_SECTION(".progmem.data")
231 typedef uint8_t PROGMEM u8g_pgm_uint8_t;
232 typedef uint8_t u8g_fntpgm_uint8_t;
233 #define u8g_pgm_read(adr) pgm_read_byte_near(adr)
234 #define U8G_PSTR(s) ((u8g_pgm_uint8_t *)PSTR(s))
235 
236 #else
237 
238 #define U8G_PROGMEM
239 #define PROGMEM
240 typedef uint8_t u8g_pgm_uint8_t;
241 typedef uint8_t u8g_fntpgm_uint8_t;
242 #define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
243 #define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
244 
245 #endif
246 
247 /*===============================================================*/
248 /* interrupt safe code */
249 #if defined(U8G_INTERRUPT_SAFE)
250 # if defined(__AVR__)
251 extern uint8_t global_SREG_backup; /* u8g_state.c */
252 # define U8G_ATOMIC_START() do { global_SREG_backup = SREG; cli(); } while(0)
253 # define U8G_ATOMIC_END() SREG = global_SREG_backup
254 # define U8G_ATOMIC_OR(ptr, val) do { uint8_t tmpSREG = SREG; cli(); (*(ptr) |= (val)); SREG = tmpSREG; } while(0)
255 # define U8G_ATOMIC_AND(ptr, val) do { uint8_t tmpSREG = SREG; cli(); (*(ptr) &= (val)); SREG = tmpSREG; } while(0)
256 # else
257 # define U8G_ATOMIC_OR(ptr, val) (*(ptr) |= (val))
258 # define U8G_ATOMIC_AND(ptr, val) (*(ptr) &= (val))
259 # define U8G_ATOMIC_START()
260 # define U8G_ATOMIC_END()
261 # endif /* __AVR__ */
262 #else
263 # define U8G_ATOMIC_OR(ptr, val) (*(ptr) |= (val))
264 # define U8G_ATOMIC_AND(ptr, val) (*(ptr) &= (val))
265 # define U8G_ATOMIC_START()
266 # define U8G_ATOMIC_END()
267 #endif /* U8G_INTERRUPT_SAFE */
268 
269 
270 /*===============================================================*/
271 /* forward */
272 typedef struct _u8g_t u8g_t;
273 typedef struct _u8g_dev_t u8g_dev_t;
274 
277 typedef struct _u8g_box_t u8g_box_t;
279 
280 
281 /*===============================================================*/
282 /* generic */
283 #if defined(U8G_16BIT)
284 typedef uint16_t u8g_uint_t;
285 typedef int16_t u8g_int_t;
286 #else
287 typedef uint8_t u8g_uint_t;
288 typedef int8_t u8g_int_t;
289 #endif
290 
291 #ifdef OBSOLETE
292 struct _u8g_box_t
293 {
294  u8g_uint_t x0, y0, x1, y1;
295 };
296 typedef struct _u8g_box_t u8g_box_t;
297 #endif /* OBSOLETE */
298 
299 
300 /*===============================================================*/
301 /* device structure */
302 
303 #ifdef __XC8
304 /* device prototype */
305 typedef uint8_t (*u8g_dev_fnptr)(void *u8g, void *dev, uint8_t msg, void *arg);
306 
307 /* com prototype */
308 typedef uint8_t (*u8g_com_fnptr)(void *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
309 #else
310 /* device prototype */
311 typedef uint8_t (*u8g_dev_fnptr)(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
312 
313 /* com prototype */
314 typedef uint8_t (*u8g_com_fnptr)(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
315 #endif
316 
317 
318 
320 {
321  u8g_dev_fnptr dev_fn; /* device procedure */
322  void *dev_mem; /* device memory */
323  u8g_com_fnptr com_fn; /* communication procedure */
324 };
325 
326 
327 /*===============================================================*/
328 /* device list */
329 
330 /* Size: 128x64 SDL, u8g_dev_sdl.c */
338 int u8g_sdl_get_key(void);
339 
340 /* Size: 70x30 monochrom, stdout */
342 
343 /* Size: monochrom, writes "u8g.pbm" */
344 extern u8g_dev_t u8g_dev_pbm;
346 extern u8g_dev_t u8g_dev_pbm_8h2; /* grayscale simulation */
347 
348 /* Size: 128x64 monochrom, no output, used for performance measure */
349 extern u8g_dev_t u8g_dev_gprof;
350 
351 /* Display: EA DOGS102, Size: 102x64 monochrom */
354 
357 
358 /* Display: Mini12864 (dealextreme), Size: 128x64 monochrom */
361 
364 
365 /* Display: EA DOGM132, Size: 128x32 monochrom */
368 
369 /* Display: EA DOGS102, Size: 102x64 monochrom */
372 
375 
376 /* Display: Mini12864 (dealextreme), Size: 128x64 monochrom */
379 
382 
383 /* Display: EA DOGM128, Size: 128x64 monochrom */
387 
391 
392 /* Display: Topway LM6059 128x64 (Adafruit) */
397 /* Display: Topway LM6063 128x64 */
402 /* Display: Newhaven NHD-C12864 */
407 
408 /* Display: Newhaven NHD-C12832 */
413 
414 /* Display: Displaytech 64128N */
418 
422 
423 /* Display: LCD-AG-C128032R-DIW W/KK E6 PBF */
426 
429 
430 /* dfrobot 128x64 Graphic LCD (SKU:FIT0021) */
435 
440 
441 /* NHD-19232WG */
445 
449 
450 /* CrystalFontz CFAG20232 */
454 
458 
459 /* LC7981 160x80 display */
461 /* LC7981 240x64 display */
463 /* LC7981 240x128 display */
465 /* LC7981 320x64 display */
467 
468 /* T6963, all t6963 devices have double page (2x) */
472 
473 /* Display: EA DOGXL160, Size: 160x104 monochrom & gray level */
478 
483 
484 /* Display: Generic KS0108b, Size: 128x64 monochrom */
485 extern u8g_dev_t u8g_dev_ks0108_128x64; /* official Arduino Library interface */
486 extern u8g_dev_t u8g_dev_ks0108_128x64_fast; /* faster, but uses private tables from the Arduino Library */
487 
488 /* Nokia 84x48 Display with PCD8544 */
492 
493 /* Nokia 96x65 Display with PCF8812 */
496 
497 /* NHD-2.7-12864UCY3 OLED Display with SSD1325 Controller */
503 
509 
510 /* LY120 OLED with SSD1327 Controller (tested with Seeedstudio module) */
514 
518 
519 /* NHD-3.12-25664 OLED Display with SSD1322 Controller */
525 
531 
532 /* OLED 128x64 Display with SSD1306 Controller */
536 
540 
541 /* OLED 128x64 Display with SSD1309 Controller */
545 
546 /* OLED 128x32 Display with SSD1306 Controller */
550 
554 
555 /* experimental 65K TFT with st7687 controller */
558 
559 /* SBN1661/SED1520 display with 122x32 */
561 
562 /* flip disc matrix */
564 void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2));
565 
566 /* ILI9325D based TFT */
568 
569 
570 /* SSD1351 OLED (breakout board from http://www.kickstarter.com/projects/ilsoftltd/colour-oled-breakout-board) */
581 
582 /* SSD1351 OLED (Freetronics, GPIOs set to high level) */
591 
592 /* HT1632 */
594 
595 /* A2 Micro Printer */
598 
599 /* u8g_virtual_screen.c */
600 extern u8g_dev_t u8g_dev_vs;
601 
602 
603 /*===============================================================*/
604 /* device messages */
605 
607 {
608  u8g_uint_t x, y; /* will be modified */
609  uint8_t pixel; /* will be modified, pixel sequence or transparency value */
610  uint8_t dir;
611  uint8_t color; /* color or index value, red value for true color mode */
612  uint8_t hi_color; /* high byte for 64K color mode, low byte is in "color", green value for true color mode */
613  uint8_t blue; /* blue value in true color mode */
614 };
615 /* typedef struct _u8g_dev_arg_pixel_t u8g_dev_arg_pixel_t; */ /* forward decl */
616 
617 /* range for r,g,b: 0..255 */
618 #define U8G_GET_HICOLOR_BY_RGB(r,g,b) (((uint16_t)((r)&0x0f8))<<8)|(((uint16_t)((g)&0x0fc))<<3)|(((uint16_t)((b)>>3)))
619 
621 {
622  u8g_uint_t x, y, w, h;
623 };
624 /* typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t; */ /* forward decl */
625 
627 {
628  u8g_uint_t x0, y0, x1, y1;
629 };
630 /* typedef struct _u8g_box_t u8g_box_t; */ /* forward decl */
631 
633 {
634  u8g_uint_t idx, r, g, b; /* index with rgb value */
635 };
636 /* typedef struct _u8g_dev_arg_irgb_t u8g_dev_arg_irgb_t; */ /* forward decl */
637 
638 
639 
640 #define U8G_DEV_MSG_INIT 10
641 #define U8G_DEV_MSG_STOP 11
642 
643 /* arg: pointer to uint8_t, contranst value between 0 and 255 */
644 #define U8G_DEV_MSG_CONTRAST 15
645 
646 #define U8G_DEV_MSG_SLEEP_ON 16
647 #define U8G_DEV_MSG_SLEEP_OFF 17
648 
649 #define U8G_DEV_MSG_PAGE_FIRST 20
650 #define U8G_DEV_MSG_PAGE_NEXT 21
651 
652 /* arg: u8g_dev_arg_bbx_t * */
653 /* new algorithm with U8G_DEV_MSG_GET_PAGE_BOX makes this msg obsolete */
654 /* #define U8G_DEV_MSG_IS_BBX_INTERSECTION 22 */
655 
656 /* arg: u8g_box_t *, fill structure with current page properties */
657 #define U8G_DEV_MSG_GET_PAGE_BOX 23
658 
659 /*
660 #define U8G_DEV_MSG_PRIMITIVE_START 30
661 #define U8G_DEV_MSG_PRIMITIVE_END 31
662 */
663 
664 /* arg: u8g_dev_arg_pixel_t * */
665 #define U8G_DEV_MSG_SET_TPIXEL 44
666 #define U8G_DEV_MSG_SET_4TPIXEL 45
667 
668 #define U8G_DEV_MSG_SET_PIXEL 50
669 #define U8G_DEV_MSG_SET_8PIXEL 59
670 
671 #define U8G_DEV_MSG_SET_COLOR_ENTRY 60
672 
673 #define U8G_DEV_MSG_SET_XY_CB 61
674 
675 #define U8G_DEV_MSG_GET_WIDTH 70
676 #define U8G_DEV_MSG_GET_HEIGHT 71
677 #define U8G_DEV_MSG_GET_MODE 72
678 
679 /*===============================================================*/
680 /* device modes */
681 #define U8G_MODE(is_index_mode, is_color, bits_per_pixel) (((is_index_mode)<<6) | ((is_color)<<5)|(bits_per_pixel))
682 
683 #define U8G_MODE_UNKNOWN 0
684 #define U8G_MODE_BW U8G_MODE(0, 0, 1)
685 #define U8G_MODE_GRAY2BIT U8G_MODE(0, 0, 2)
686 #define U8G_MODE_R3G3B2 U8G_MODE(0, 1, 8)
687 #define U8G_MODE_INDEX U8G_MODE(1, 1, 8)
688 /* hicolor is R5G6B5 */
689 #define U8G_MODE_HICOLOR U8G_MODE(0, 1, 16)
690 /* truecolor */
691 #define U8G_MODE_TRUECOLOR U8G_MODE(0, 1, 24)
692 
693 
694 #define U8G_MODE_GET_BITS_PER_PIXEL(mode) ((mode)&31)
695 #define U8G_MODE_IS_COLOR(mode) (((mode)&32)==0?0:1)
696 #define U8G_MODE_IS_INDEX_MODE(mode) (((mode)&64)==0?0:1)
697 
698 
699 /*===============================================================*/
700 /* com options */
701 
702 /* uncomment the following line for Atmega HW SPI double speed, issue 89 */
703 /* #define U8G_HW_SPI_2X 1 */
704 
705 /* com messages */
706 
707 #define U8G_COM_MSG_STOP 0
708 #define U8G_COM_MSG_INIT 1
709 
710 #define U8G_COM_MSG_ADDRESS 2
711 
712 /* CHIP_SELECT argument: number of the chip which needs to be activated, so this is more like high active */
713 #define U8G_COM_MSG_CHIP_SELECT 3
714 
715 #define U8G_COM_MSG_RESET 4
716 
717 #define U8G_COM_MSG_WRITE_BYTE 5
718 #define U8G_COM_MSG_WRITE_SEQ 6
719 #define U8G_COM_MSG_WRITE_SEQ_P 7
720 
721 
722 /* com driver */
723 uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_null.c */
724 uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_std_sw_spi.c */
725 uint8_t u8g_com_arduino_hw_usart_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_hw_usart_spi.c */
726 uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_sw_spi.c */
727 uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_hw_spi.c */
728 uint8_t u8g_com_arduino_ATtiny85_std_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_arduino_ATTiny85_std_hw_spi.c */
729 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_spi.c */
730 uint8_t u8g_com_arduino_st7920_custom_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_custom.c */
731 uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_hw_spi.c */
732 uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_parallel.c */
733 uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_fast_parallel.c */
734 uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_port_d_wr.c */
735 uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_no_en_parallel.c */
736 uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_ssd_i2c.c */
737 uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_t6963.c */
738 
739 
740 uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_hw_spi.c */
741 uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_sw_spi.c */
742 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_st7920_spi.c */
743 uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
744 uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_parallel.c */
745 
746 
747 /*
748  Translation of system specific com drives to generic com names
749  At the moment, the following generic com drives are available
750  U8G_COM_HW_SPI
751  U8G_COM_SW_SPI
752  U8G_COM_PARALLEL
753  U8G_COM_T6963
754  U8G_COM_FAST_PARALLEL
755  U8G_COM_SSD_I2C
756 
757 defined(__18CXX) || defined(__PIC32MX)
758 
759 */
760 /* ==== HW SPI, Arduino ====*/
761 #if defined(ARDUINO)
762 #if defined(__AVR__)
763 
764 #if defined(__AVR_ATtiny85__)
765 #define U8G_COM_HW_SPI u8g_com_arduino_ATtiny85_std_hw_spi_fn
766 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
767 #else
768 
769 #define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
770 #if defined(__AVR_ATmega32U4__)
771 #define U8G_COM_HW_USART_SPI u8g_com_arduino_hw_usart_spi_fn
772 #endif /* __AVR_ATmega32U4__ */
773 #define U8G_COM_ST7920_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
774 #endif /* __AVR_ATtiny85__ */
775 
776 #elif defined(__18CXX) || defined(__PIC32MX)
777 #define U8G_COM_HW_SPI u8g_com_null_fn
778 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
779 #elif defined(__arm__) /* Arduino Due */
780 #define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
781 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
782 #endif
783 #endif
784 /* ==== HW SPI, not Arduino ====*/
785 #ifndef U8G_COM_HW_SPI
786 #if defined(__AVR__)
787 #define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
788 #define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
789 #endif
790 #endif
791 #ifndef U8G_COM_HW_SPI
792 #define U8G_COM_HW_SPI u8g_com_null_fn
793 #define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
794 #endif
795 
796 #ifndef U8G_COM_HW_USART_SPI
797 #define U8G_COM_HW_USART_SPI u8g_com_null_fn
798 #endif
799 
800 
801 /* ==== SW SPI, Arduino ====*/
802 #if defined(ARDUINO)
803 #if defined(__AVR__)
804 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
805 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
806 #elif defined(__18CXX) || defined(__PIC32MX)
807 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
808 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
809 #elif defined(__arm__) /* Arduino Due */
810 //#define U8G_COM_SW_SPI u8g_com_arduino_std_sw_spi_fn
811 #define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
812 #define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
813 #endif
814 #endif
815 
816 #ifndef U8G_COM_SW_SPI
817 /* ==== SW SPI, not Arduino ====*/
818 #if defined(__AVR__)
819 #define U8G_COM_SW_SPI u8g_com_atmega_sw_spi_fn
820 #define U8G_COM_ST7920_SW_SPI u8g_com_atmega_st7920_sw_spi_fn
821 #endif
822 #endif
823 #ifndef U8G_COM_SW_SPI
824 #define U8G_COM_SW_SPI u8g_com_null_fn
825 #define U8G_COM_ST7920_SW_SPI u8g_com_null_fn
826 #endif
827 
828 /* ==== Parallel iinterface, Arduino ====*/
829 #if defined(ARDUINO)
830 #if defined(__AVR__)
831 #define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
832 #define U8G_COM_FAST_PARALLEL u8g_com_arduino_fast_parallel_fn
833 #define U8G_COM_T6963 u8g_com_arduino_t6963_fn
834 #else /* Arduino Due, Chipkit PIC32 */
835 #define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
836 #define U8G_COM_FAST_PARALLEL u8g_com_arduino_parallel_fn
837 #define U8G_COM_T6963 u8g_com_null_fn
838 #endif
839 #endif
840 #ifndef U8G_COM_PARALLEL
841 #if defined(__AVR__)
842 #define U8G_COM_PARALLEL u8g_com_atmega_parallel_fn
843 #define U8G_COM_FAST_PARALLEL u8g_com_atmega_parallel_fn
844 #define U8G_COM_T6963 u8g_com_null_fn
845 #endif
846 #endif
847 #ifndef U8G_COM_PARALLEL
848 #define U8G_COM_PARALLEL u8g_com_null_fn
849 #define U8G_COM_FAST_PARALLEL u8g_com_null_fn
850 #define U8G_COM_T6963 u8g_com_null_fn
851 #endif
852 
853 #if defined(ARDUINO)
854 #if defined(__AVR__)
855 #define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
856 #endif
857 #endif
858 
859 #ifndef U8G_COM_SSD_I2C
860 #if defined(__AVR__) || defined(__SAM3X8E__)
861 /* AVR variant can use the arduino version at the moment */
862 #define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
863 #endif
864 #endif
865 #ifndef U8G_COM_SSD_I2C
866 #define U8G_COM_SSD_I2C u8g_com_null_fn
867 #endif
868 
869 
870 
871 /*===============================================================*/
872 /* com api */
873 
874 #define U8G_SPI_CLK_CYCLE_50NS 1
875 #define U8G_SPI_CLK_CYCLE_300NS 2
876 #define U8G_SPI_CLK_CYCLE_400NS 3
877 #define U8G_SPI_CLK_CYCLE_500NS 4
878 #define U8G_SPI_CLK_CYCLE_NONE 255
879 
880 uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time);
881 void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev);
882 void u8g_EnableCom(u8g_t *u8g, u8g_dev_t *dev); /* obsolete */
883 void u8g_DisableCom(u8g_t *u8g, u8g_dev_t *dev); /* obsolete */
884 void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs);
885 void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev);
886 void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev);
887 void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address);
888 uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val);
889 uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq);
890 uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq);
891 
892 
893 
894 #define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
895 #define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
896 #define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
897 #define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
898 #define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
899 #define U8G_ESC_END 255, 254
900 #define U8G_ESC_255 255, 255
901 //uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, u8g_pgm_uint8_t *esc_seq);
902 uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq);
903 
904 
905 /* u8g_com_api_16gr.c */
906 uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
907 uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
908 uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
909 uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
910 
911 
912 /*===============================================================*/
913 /* u8g_arduino_common.c */
914 void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value);
916 
917 /*===============================================================*/
918 /* u8g_com_io.c */
919 
920 /* create internal number from port and pin */
921 uint8_t u8g_Pin(uint8_t port, uint8_t bitpos);
922 #define PN(port,bitpos) u8g_Pin(port,bitpos)
923 
924 /* low level procedures */
925 void u8g_SetPinOutput(uint8_t internal_pin_number);
926 void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level);
927 void u8g_SetPinInput(uint8_t internal_pin_number);
928 uint8_t u8g_GetPinLevel(uint8_t internal_pin_number);
929 
930 /* u8g level procedures, expect U8G_PI_xxx macro */
931 void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi);
932 void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level);
933 
934 
935 /*===============================================================*/
936 /* page */
938 {
939  u8g_uint_t page_height;
940  u8g_uint_t total_height;
941  u8g_uint_t page_y0;
942  u8g_uint_t page_y1;
943  uint8_t page;
944 };
945 typedef struct _u8g_page_t u8g_page_t;
946 
947 void u8g_page_First(u8g_page_t *p) U8G_NOINLINE; /* u8g_page.c */
948 void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height ) U8G_NOINLINE; /* u8g_page.c */
949 uint8_t u8g_page_Next(u8g_page_t *p) U8G_NOINLINE; /* u8g_page.c */
950 
951 /*===============================================================*/
952 /* page buffer (pb) */
953 
954 struct _u8g_pb_t
955 {
957  u8g_uint_t width; /* pixel width */
958  void *buf;
959 };
960 typedef struct _u8g_pb_t u8g_pb_t;
961 
962 
963 /* u8g_pb.c */
964 void u8g_pb_Clear(u8g_pb_t *b);
965 uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1);
966 uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
968 void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box);
969 uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel);
970 uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
971 
972 /*
973  note on __attribute__ ((nocommon))
974  AVR scripts often use --gc-sections on the linker to remove unused section.
975  This works fine for initialed data and text sections. In principle .bss is also
976  handled, but the name##_pb definition is not removed. Reason is, that
977  array definitions are placed in the COMMON section, by default
978  The attribute "nocommon" removes this automatic assignment to the
979  COMMON section and directly puts it into .bss. As a result, if more
980  than one buffer is defined in one file, then it will be removed with --gc-sections
981 
982  .. not sure if Arduino IDE uses -fno-common... if yes, then the attribute is
983  redundant.
984 */
985 #define U8G_PB_DEV(name, width, height, page_height, dev_fn, com_fn) \
986 uint8_t name##_buf[width] U8G_NOCOMMON ; \
987 u8g_pb_t name##_pb = { {page_height, height, 0, 0, 0}, width, name##_buf}; \
988 u8g_dev_t name = { dev_fn, &name##_pb, com_fn }
989 
990 
991 void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
993 
994 uint8_t u8g_pb8v1_IsYIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
995 uint8_t u8g_pb8v1_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
996 uint8_t u8g_pb8v1_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
997 
998 uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
999 
1000 /* u8g_pb16v1.c */
1001 uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1002 
1003 /* u8g_pb14v1.c */
1004 uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1005 
1006 /* u8g_pb8v2.c */
1007 uint8_t u8g_dev_pb8v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1008 
1009 /* u8g_pb16v2.c (double memory of pb8v2) */
1010 uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1011 
1012 
1013 /* u8g_pb8h1.c */
1014 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1015 
1016 /* u8g_pb16h1.c */
1017 uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1018 
1019 /* u8g_pb32h1.c */
1020 uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1021 
1022 
1023 /* u8g_pb8h2.c 8 pixel rows, byte has horzontal orientation */
1024 uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1025 
1026 /* u8g_pb16h2.c */
1027 uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1028 
1029 
1030 
1031 /* u8g_pb8h1f.c */
1032 uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1033 
1034 /* u8g_pb8h8.c */
1035 uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1036 
1037 /* u8g_pbxh16.c */
1038 uint8_t u8g_dev_pbxh16_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1039 
1040 /* u8g_pbxh24.c */
1041 uint8_t u8g_dev_pbxh24_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1042 
1043 
1044 /*===============================================================*/
1045 /* u8g_ll_api.c */
1046 
1047 /* cursor draw callback */
1048 typedef void (*u8g_draw_cursor_fn)(u8g_t *u8g);
1049 
1050 /* vertical reference point calculation callback */
1052 
1053 /* state backup and restore procedure */
1054 typedef void (*u8g_state_cb)(uint8_t msg);
1055 
1056 
1057 /* PI = Pin Index */
1058 
1059 /* reset pin, usually optional */
1060 #define U8G_PI_RESET 0
1061 
1062 /* address / data or instruction */
1063 #define U8G_PI_A0 1
1064 #define U8G_PI_DI 1
1065 
1066 /* chip select line */
1067 #define U8G_PI_CS 2
1068 #define U8G_PI_CS1 2
1069 #define U8G_PI_CS2 3
1070 /* Feb 2013: A0 state moved from 7 to 3 for t6963 controller*/
1071 #define U8G_PI_A0_STATE 3
1072 
1073 /* enable / clock signal */
1074 #define U8G_PI_EN 4
1075 #define U8G_PI_CS_STATE 4
1076 #define U8G_PI_SCK 4
1077 #define U8G_PI_SCL 4
1078 #define U8G_PI_RD 4
1079 
1080 
1081 /* data pins, shared with SPI and I2C pins */
1082 #define U8G_PI_D0 5
1083 #define U8G_PI_MOSI 5
1084 #define U8G_PI_SDA 5
1085 #define U8G_PI_D1 6
1086 #define U8G_PI_MISO 6
1087 #define U8G_PI_D2 7
1088 #define U8G_PI_D3 8
1089 #define U8G_PI_SET_A0 8
1090 #define U8G_PI_D4 9
1091 #define U8G_PI_D5 10
1092 #define U8G_PI_I2C_OPTION 11
1093 #define U8G_PI_D6 11
1094 #define U8G_PI_D7 12
1095 
1096 /* read/write pin, must be the last pin in the list, this means U8G_PIN_LIST_LEN = U8G_PI_RW + 1*/
1097 #define U8G_PI_WR 13
1098 #define U8G_PI_RW 13
1099 
1100 #define U8G_PIN_LIST_LEN 14
1101 
1102 
1103 #define U8G_PIN_DUMMY 254
1104 #define U8G_PIN_NONE 255
1105 
1106 #define U8G_FONT_HEIGHT_MODE_TEXT 0
1107 #define U8G_FONT_HEIGHT_MODE_XTEXT 1
1108 #define U8G_FONT_HEIGHT_MODE_ALL 2
1109 
1110 struct _u8g_t
1111 {
1112  u8g_uint_t width;
1113  u8g_uint_t height;
1114 
1115 
1116  u8g_dev_t *dev; /* first device in the device chain */
1117  const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
1118  const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
1119  uint8_t cursor_fg_color, cursor_bg_color;
1121  uint8_t mode; /* display mode, one of U8G_MODE_xxx */
1122  u8g_uint_t cursor_x;
1123  u8g_uint_t cursor_y;
1125 
1126  int8_t glyph_dx;
1127  int8_t glyph_x;
1128  int8_t glyph_y;
1129  uint8_t glyph_width;
1130  uint8_t glyph_height;
1131 
1136  uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
1137  uint8_t line_spacing;
1138 
1140  /* uint8_t color_index; */
1141 
1142 #ifdef U8G_WITH_PINLIST
1143  uint8_t pin_list[U8G_PIN_LIST_LEN];
1144 #endif
1145 
1147 
1148  u8g_box_t current_page; /* current box of the visible page */
1149 
1150 };
1151 
1152 #define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
1153 #define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
1154 #define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
1155 
1156 uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
1157 
1158 uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev);
1159 void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev);
1160 uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev);
1161 uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast);
1162 void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y);
1163 void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
1164 void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
1165 uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h); /* obsolete */
1166 u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev);
1167 u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev);
1168 
1169 void u8g_UpdateDimension(u8g_t *u8g);
1170 uint8_t u8g_Begin(u8g_t *u8g); /* reset device, put it into default state and call u8g_UpdateDimension() */
1171 uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev); /* only usefull if the device only as hardcoded ports */
1172 uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn); /* Init procedure for anything which is not Arduino or AVR (e.g. ARM, but not Due, which is Arduino) */
1173 uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset);
1174 uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset);
1175 uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options); /* use U8G_I2C_OPT_NONE as options */
1176 uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset);
1177 uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
1178  uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset);
1179 uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
1180  uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
1181 void u8g_FirstPage(u8g_t *u8g);
1182 uint8_t u8g_NextPage(u8g_t *u8g);
1183 uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast);
1184 void u8g_SleepOn(u8g_t *u8g);
1185 void u8g_SleepOff(u8g_t *u8g);
1186 void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y);
1187 void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
1188 void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
1189 
1190 uint8_t u8g_Stop(u8g_t *u8g);
1191 void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
1192 void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx);
1193 void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb);
1194 void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b);
1195 void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b);
1196 uint8_t u8g_GetColorIndex(u8g_t *u8g);
1197 
1198 uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g);
1200 
1201 uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g);
1203 
1204 uint8_t u8g_GetDefaultMidColor(u8g_t *u8g);
1205 void u8g_SetDefaultMidColor(u8g_t *u8g);
1206 
1207 #define u8g_GetWidth(u8g) ((u8g)->width)
1208 #define u8g_GetHeight(u8g) ((u8g)->height)
1209 #define u8g_GetMode(u8g) ((u8g)->mode)
1210 /*
1211  U8G_MODE_GET_BITS_PER_PIXEL(u8g_GetMode(u8g))
1212  U8G_MODE_IS_COLOR(u8g_GetMode(u8g))
1213 */
1214 
1215 /* u8g_state.c */
1216 #define U8G_STATE_ENV_IDX 0
1217 #define U8G_STATE_U8G_IDX 1
1218 #define U8G_STATE_RESTORE 0
1219 #define U8G_STATE_BACKUP 1
1220 #define U8G_STATE_MSG_COMPOSE(cmd,idx) (((cmd)<<1) | (idx))
1221 
1222 #define U8G_STATE_MSG_RESTORE_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_ENV_IDX)
1223 #define U8G_STATE_MSG_BACKUP_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_ENV_IDX)
1224 #define U8G_STATE_MSG_RESTORE_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_U8G_IDX)
1225 #define U8G_STATE_MSG_BACKUP_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_U8G_IDX)
1226 
1227 #define U8G_STATE_MSG_GET_IDX(msg) ((msg)&1)
1228 #define U8G_STATE_MSG_IS_BACKUP(msg) ((msg)&2)
1229 
1230 
1231 
1232 void u8g_state_dummy_cb(uint8_t msg);
1233 void u8g_backup_spi(uint8_t msg); /* backup SPI state controller */
1234 /* backward compatible definition */
1235 #define u8g_backup_avr_spi u8g_backup_spi
1236 
1237 void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb);
1238 
1239 /* u8g_clip.c */
1240 
1241 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
1242 
1243 
1244 /* u8g_rot.c */
1245 
1246 void u8g_UndoRotation(u8g_t *u8g);
1247 void u8g_SetRot90(u8g_t *u8g);
1248 void u8g_SetRot180(u8g_t *u8g);
1249 void u8g_SetRot270(u8g_t *u8g);
1250 
1251 /* u8g_scale.c */
1252 
1253 void u8g_UndoScale(u8g_t *u8g);
1254 void u8g_SetScale2x2(u8g_t *u8g);
1255 
1256 
1257 /* u8g_font.c */
1258 
1259 size_t u8g_font_GetSize(const void *font);
1260 uint8_t u8g_font_GetFontStartEncoding(const void *font) U8G_NOINLINE;
1261 uint8_t u8g_font_GetFontEndEncoding(const void *font) U8G_NOINLINE;
1262 
1263 void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font);
1264 
1265 uint8_t u8g_GetFontBBXWidth(u8g_t *u8g);
1266 uint8_t u8g_GetFontBBXHeight(u8g_t *u8g);
1267 int8_t u8g_GetFontBBXOffX(u8g_t *u8g);
1268 int8_t u8g_GetFontBBXOffY(u8g_t *u8g);
1269 uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g);
1270 
1271 uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding);
1272 int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding);
1273 
1274 int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding); /* used by u8g_cursor.c */
1275 
1276 int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
1277 int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
1278 int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
1279 int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
1280 int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
1281 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
1282 
1283 u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
1284 u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
1285 u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
1286 u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
1287 
1288 u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
1289 
1290 
1291 u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
1292 u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
1293 u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
1294 u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
1295 
1296 
1297 void u8g_SetFontRefHeightText(u8g_t *u8g);
1299 void u8g_SetFontRefHeightAll(u8g_t *u8g);
1300 void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor);
1301 
1302 u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g);
1303 u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g);
1304 u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g);
1305 u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g);
1306 
1307 void u8g_SetFontPosBaseline(u8g_t *u8g);
1308 void u8g_SetFontPosBottom(u8g_t *u8g);
1309 void u8g_SetFontPosCenter(u8g_t *u8g);
1310 void u8g_SetFontPosTop(u8g_t *u8g);
1311 
1312 
1313 u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s);
1314 u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
1315 int8_t u8g_GetStrX(u8g_t *u8g, const char *s);
1316 int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
1317 u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s);
1318 u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
1319 
1320 u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
1321 
1322 void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
1323 void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
1324 
1325 
1326 u8g_uint_t u8g_DrawAAStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
1327 
1328 /* u8g_rect.c */
1329 
1330 void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) U8G_NOINLINE;
1331 
1332 void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
1333 void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
1334 void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
1335 void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
1336 
1337 void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
1338 void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
1339 
1340 /* u8g_bitmap.c */
1341 
1342 void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap);
1343 void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap);
1344 void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap);
1345 void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap);
1346 
1347 void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap);
1348 void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap);
1349 
1350 
1351 /* u8g_line.c */
1352 void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2);
1353 
1354 
1355 /* u8g_circle.c */
1356 
1357 /* the following, commented code has been rewritten or is not yet finished
1358 #define U8G_CIRC_UPPER_RIGHT 0x01
1359 #define U8G_CIRC_UPPER_LEFT 0x02
1360 #define U8G_CIRC_LOWER_LEFT 0x04
1361 #define U8G_CIRC_LOWER_RIGHT 0x08
1362 #define U8G_CIRC_ALL (U8G_CIRC_UPPER_RIGHT|U8G_CIRC_UPPER_LEFT|U8G_CIRC_LOWER_RIGHT|U8G_CIRC_LOWER_LEFT)
1363 void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
1364 void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
1365 void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1);
1366 */
1367 
1368 #define U8G_DRAW_UPPER_RIGHT 0x01
1369 #define U8G_DRAW_UPPER_LEFT 0x02
1370 #define U8G_DRAW_LOWER_LEFT 0x04
1371 #define U8G_DRAW_LOWER_RIGHT 0x08
1372 #define U8G_DRAW_ALL (U8G_DRAW_UPPER_RIGHT|U8G_DRAW_UPPER_LEFT|U8G_DRAW_LOWER_RIGHT|U8G_DRAW_LOWER_LEFT)
1373 
1374 void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
1375 void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
1376 
1377 void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
1378 void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
1379 
1380 /* u8g_ellipse.c */
1381 void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option);
1382 void u8g_DrawFilledEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option);
1383 
1384 /* u8g_clip.c */
1385 uint8_t u8g_is_box_bbx_intersection(u8g_box_t *box, u8g_dev_arg_bbx_t *bbx);
1386 
1387 
1388 /* u8g_cursor.c */
1389 void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font);
1390 void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding);
1391 void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y);
1392 void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg);
1393 void u8g_EnableCursor(u8g_t *u8g);
1394 void u8g_DisableCursor(u8g_t *u8g);
1395 void u8g_DrawCursor(u8g_t *u8g);
1396 
1397 
1398 
1399 /*===============================================================*/
1400 /* u8g_virtual_screen.c */
1401 void u8g_SetVirtualScreenDimension(u8g_t *vs_u8g, u8g_uint_t width, u8g_uint_t height);
1402 uint8_t u8g_AddToVirtualScreen(u8g_t *vs_u8g, u8g_uint_t x, u8g_uint_t y, u8g_t *child_u8g);
1403 
1404 /*===============================================================*/
1405 void st_Draw(uint8_t fps);
1406 void st_Step(uint8_t player_pos, uint8_t is_auto_fire, uint8_t is_fire);
1407 
1408 /*===============================================================*/
1409 /* u8g_com_i2c.c */
1410 
1411 /* options for u8g_i2c_init() */
1412 #define U8G_I2C_OPT_NONE 0
1413 #define U8G_I2C_OPT_NO_ACK 2
1414 #define U8G_I2C_OPT_DEV_0 0
1415 #define U8G_I2C_OPT_DEV_1 4
1416 #define U8G_I2C_OPT_FAST 16
1417 
1418 /* u8g_com_i2c.c */
1419 
1420 /* retrun values from u8g_twi_get_error() */
1421 #define U8G_I2C_ERR_NONE 0x00
1422 /* the following values are bit masks */
1423 #define U8G_I2C_ERR_TIMEOUT 0x01
1424 #define U8G_I2C_ERR_BUS 0x02
1425 
1427 uint8_t u8g_i2c_get_error(void) U8G_NOINLINE;
1428 uint8_t u8g_i2c_get_err_pos(void) U8G_NOINLINE;
1429 void u8g_i2c_init(uint8_t options) U8G_NOINLINE; /* use U8G_I2C_OPT_NONE as options */
1430 uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) U8G_NOINLINE;
1431 uint8_t u8g_i2c_start(uint8_t sla) U8G_NOINLINE;
1432 uint8_t u8g_i2c_send_byte(uint8_t data) U8G_NOINLINE;
1433 void u8g_i2c_stop(void) U8G_NOINLINE;
1434 
1435 
1436 /*===============================================================*/
1437 /* u8g_u8toa.c */
1438 /* v = value, d = number of digits */
1439 const char *u8g_u8toa(uint8_t v, uint8_t d);
1440 
1441 /* u8g_u8toa.c */
1442 /* v = value, d = number of digits */
1443 const char *u8g_u16toa(uint16_t v, uint8_t d);
1444 
1445 /*===============================================================*/
1446 /* u8g_delay.c */
1447 
1448 /* delay by the specified number of milliseconds */
1449 void u8g_Delay(uint16_t val);
1450 
1451 /* delay by one microsecond */
1452 void u8g_MicroDelay(void);
1453 
1454 /* delay by 10 microseconds */
1455 void u8g_10MicroDelay(void);
1456 
1457 /*===============================================================*/
1458 /* chessengine.c */
1459 #define CHESS_KEY_NONE 0
1460 #define CHESS_KEY_NEXT 1
1461 #define CHESS_KEY_PREV 2
1462 #define CHESS_KEY_SELECT 3
1463 #define CHESS_KEY_BACK 4
1464 
1465 void chess_Init(u8g_t *u8g, uint8_t empty_body_color);
1466 void chess_Draw(void);
1467 void chess_Step(uint8_t keycode);
1468 
1469 /*===============================================================*/
1470 /* font definitions */
1471 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_FONT_SECTION("u8g_font_m2icon_5");
1472 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_7[] U8G_FONT_SECTION("u8g_font_m2icon_7");
1473 extern const u8g_fntpgm_uint8_t u8g_font_m2icon_9[] U8G_FONT_SECTION("u8g_font_m2icon_9");
1474 
1475 extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4[] U8G_FONT_SECTION("u8g_font_u8glib_4");
1476 extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4r[] U8G_FONT_SECTION("u8g_font_u8glib_4r");
1477 
1478 
1479 extern const u8g_fntpgm_uint8_t u8g_font_6x12_75r[] U8G_FONT_SECTION("u8g_font_6x12_75r");
1480 extern const u8g_fntpgm_uint8_t u8g_font_6x13_75r[] U8G_FONT_SECTION("u8g_font_6x13_75r");
1481 extern const u8g_fntpgm_uint8_t u8g_font_7x13_75r[] U8G_FONT_SECTION("u8g_font_7x13_75r");
1482 extern const u8g_fntpgm_uint8_t u8g_font_8x13_75r[] U8G_FONT_SECTION("u8g_font_8x13_75r");
1483 extern const u8g_fntpgm_uint8_t u8g_font_9x15_75r[] U8G_FONT_SECTION("u8g_font_9x15_75r");
1484 extern const u8g_fntpgm_uint8_t u8g_font_9x18_75r[] U8G_FONT_SECTION("u8g_font_9x18_75r");
1485 extern const u8g_fntpgm_uint8_t u8g_font_cu12_75r[] U8G_FONT_SECTION("u8g_font_cu12_75r");
1486 extern const u8g_fntpgm_uint8_t u8g_font_unifont_75r[] U8G_FONT_SECTION("u8g_font_unifont_75r");
1487 extern const u8g_fntpgm_uint8_t u8g_font_10x20_75r[] U8G_FONT_SECTION("u8g_font_10x20_75r");
1488 
1489 extern const u8g_fntpgm_uint8_t u8g_font_10x20_67_75[] U8G_FONT_SECTION("u8g_font_10x20_67_75");
1490 extern const u8g_fntpgm_uint8_t u8g_font_10x20_78_79[] U8G_FONT_SECTION("u8g_font_10x20_78_79");
1491 extern const u8g_fntpgm_uint8_t u8g_font_10x20[] U8G_FONT_SECTION("u8g_font_10x20");
1492 extern const u8g_fntpgm_uint8_t u8g_font_10x20r[] U8G_FONT_SECTION("u8g_font_10x20r");
1493 extern const u8g_fntpgm_uint8_t u8g_font_4x6[] U8G_FONT_SECTION("u8g_font_4x6");
1494 extern const u8g_fntpgm_uint8_t u8g_font_4x6r[] U8G_FONT_SECTION("u8g_font_4x6r");
1495 //extern const u8g_fntpgm_uint8_t u8g_font_4x6n[] U8G_FONT_SECTION("u8g_font_4x6n");
1496 extern const u8g_fntpgm_uint8_t u8g_font_5x7[] U8G_FONT_SECTION("u8g_font_5x7");
1497 extern const u8g_fntpgm_uint8_t u8g_font_5x7r[] U8G_FONT_SECTION("u8g_font_5x7r");
1498 extern const u8g_fntpgm_uint8_t u8g_font_5x8[] U8G_FONT_SECTION("u8g_font_5x8");
1499 extern const u8g_fntpgm_uint8_t u8g_font_5x8r[] U8G_FONT_SECTION("u8g_font_5x8r");
1500 extern const u8g_fntpgm_uint8_t u8g_font_6x10[] U8G_FONT_SECTION("u8g_font_6x10");
1501 extern const u8g_fntpgm_uint8_t u8g_font_6x10r[] U8G_FONT_SECTION("u8g_font_6x10r");
1502 extern const u8g_fntpgm_uint8_t u8g_font_6x12_67_75[] U8G_FONT_SECTION("u8g_font_6x12_67_75");
1503 extern const u8g_fntpgm_uint8_t u8g_font_6x12_78_79[] U8G_FONT_SECTION("u8g_font_6x12_78_79");
1504 extern const u8g_fntpgm_uint8_t u8g_font_6x12[] U8G_FONT_SECTION("u8g_font_6x12");
1505 extern const u8g_fntpgm_uint8_t u8g_font_6x12r[] U8G_FONT_SECTION("u8g_font_6x12r");
1506 extern const u8g_fntpgm_uint8_t u8g_font_6x13_67_75[] U8G_FONT_SECTION("u8g_font_6x13_67_75");
1507 extern const u8g_fntpgm_uint8_t u8g_font_6x13_78_79[] U8G_FONT_SECTION("u8g_font_6x13_78_79");
1508 extern const u8g_fntpgm_uint8_t u8g_font_6x13B[] U8G_FONT_SECTION("u8g_font_6x13B");
1509 extern const u8g_fntpgm_uint8_t u8g_font_6x13Br[] U8G_FONT_SECTION("u8g_font_6x13Br");
1510 extern const u8g_fntpgm_uint8_t u8g_font_6x13[] U8G_FONT_SECTION("u8g_font_6x13");
1511 extern const u8g_fntpgm_uint8_t u8g_font_6x13r[] U8G_FONT_SECTION("u8g_font_6x13r");
1512 extern const u8g_fntpgm_uint8_t u8g_font_6x13O[] U8G_FONT_SECTION("u8g_font_6x13O");
1513 extern const u8g_fntpgm_uint8_t u8g_font_6x13Or[] U8G_FONT_SECTION("u8g_font_6x13Or");
1514 extern const u8g_fntpgm_uint8_t u8g_font_7x13_67_75[] U8G_FONT_SECTION("u8g_font_7x13_67_75");
1515 extern const u8g_fntpgm_uint8_t u8g_font_7x13_78_79[] U8G_FONT_SECTION("u8g_font_7x13_78_79");
1516 extern const u8g_fntpgm_uint8_t u8g_font_7x13B[] U8G_FONT_SECTION("u8g_font_7x13B");
1517 extern const u8g_fntpgm_uint8_t u8g_font_7x13Br[] U8G_FONT_SECTION("u8g_font_7x13Br");
1518 extern const u8g_fntpgm_uint8_t u8g_font_7x13[] U8G_FONT_SECTION("u8g_font_7x13");
1519 extern const u8g_fntpgm_uint8_t u8g_font_7x13r[] U8G_FONT_SECTION("u8g_font_7x13r");
1520 extern const u8g_fntpgm_uint8_t u8g_font_7x13O[] U8G_FONT_SECTION("u8g_font_7x13O");
1521 extern const u8g_fntpgm_uint8_t u8g_font_7x13Or[] U8G_FONT_SECTION("u8g_font_7x13Or");
1522 extern const u8g_fntpgm_uint8_t u8g_font_7x14B[] U8G_FONT_SECTION("u8g_font_7x14B");
1523 extern const u8g_fntpgm_uint8_t u8g_font_7x14Br[] U8G_FONT_SECTION("u8g_font_7x14Br");
1524 extern const u8g_fntpgm_uint8_t u8g_font_7x14[] U8G_FONT_SECTION("u8g_font_7x14");
1525 extern const u8g_fntpgm_uint8_t u8g_font_7x14r[] U8G_FONT_SECTION("u8g_font_7x14r");
1526 extern const u8g_fntpgm_uint8_t u8g_font_8x13_67_75[] U8G_FONT_SECTION("u8g_font_8x13_67_75");
1527 extern const u8g_fntpgm_uint8_t u8g_font_8x13B[] U8G_FONT_SECTION("u8g_font_8x13B");
1528 extern const u8g_fntpgm_uint8_t u8g_font_8x13Br[] U8G_FONT_SECTION("u8g_font_8x13Br");
1529 extern const u8g_fntpgm_uint8_t u8g_font_8x13[] U8G_FONT_SECTION("u8g_font_8x13");
1530 extern const u8g_fntpgm_uint8_t u8g_font_8x13r[] U8G_FONT_SECTION("u8g_font_8x13r");
1531 extern const u8g_fntpgm_uint8_t u8g_font_8x13O[] U8G_FONT_SECTION("u8g_font_8x13O");
1532 extern const u8g_fntpgm_uint8_t u8g_font_8x13Or[] U8G_FONT_SECTION("u8g_font_8x13Or");
1533 
1534 extern const u8g_fntpgm_uint8_t u8g_font_9x15_67_75[] U8G_FONT_SECTION("u8g_font_9x15_67_75");
1535 extern const u8g_fntpgm_uint8_t u8g_font_9x15_78_79[] U8G_FONT_SECTION("u8g_font_9x15_78_79");
1536 extern const u8g_fntpgm_uint8_t u8g_font_9x15B[] U8G_FONT_SECTION("u8g_font_9x15B");
1537 extern const u8g_fntpgm_uint8_t u8g_font_9x15Br[] U8G_FONT_SECTION("u8g_font_9x15Br");
1538 extern const u8g_fntpgm_uint8_t u8g_font_9x15[] U8G_FONT_SECTION("u8g_font_9x15");
1539 extern const u8g_fntpgm_uint8_t u8g_font_9x15r[] U8G_FONT_SECTION("u8g_font_9x15r");
1540 
1541 extern const u8g_fntpgm_uint8_t u8g_font_9x18_67_75[] U8G_FONT_SECTION("u8g_font_9x18_67_75");
1542 extern const u8g_fntpgm_uint8_t u8g_font_9x18_78_79[] U8G_FONT_SECTION("u8g_font_9x18_78_79");
1543 extern const u8g_fntpgm_uint8_t u8g_font_9x18B[] U8G_FONT_SECTION("u8g_font_9x18B");
1544 extern const u8g_fntpgm_uint8_t u8g_font_9x18[] U8G_FONT_SECTION("u8g_font_9x18");
1545 extern const u8g_fntpgm_uint8_t u8g_font_9x18Br[] U8G_FONT_SECTION("u8g_font_9x18Br");
1546 extern const u8g_fntpgm_uint8_t u8g_font_9x18r[] U8G_FONT_SECTION("u8g_font_9x18r");
1547 
1548 extern const u8g_fntpgm_uint8_t u8g_font_cursor[] U8G_FONT_SECTION("u8g_font_cursor");
1549 extern const u8g_fntpgm_uint8_t u8g_font_cursorr[] U8G_FONT_SECTION("u8g_font_cursorr");
1550 extern const u8g_fntpgm_uint8_t u8g_font_micro[] U8G_FONT_SECTION("u8g_font_micro");
1551 
1552 extern const u8g_fntpgm_uint8_t u8g_font_cu12_67_75[] U8G_FONT_SECTION("u8g_font_cu12_67_75");
1553 extern const u8g_fntpgm_uint8_t u8g_font_cu12_78_79[] U8G_FONT_SECTION("u8g_font_cu12_78_79");
1554 extern const u8g_fntpgm_uint8_t u8g_font_cu12[] U8G_FONT_SECTION("u8g_font_cu12");
1555 
1556 /*
1557  Free-Universal Bold
1558  r: Reduced char set (codes 32 - 128)
1559  n: Numbers (codes 42 - 57)
1560  no char: Full set (codes 32 - 255)
1561 */
1562 
1563 extern const u8g_fntpgm_uint8_t u8g_font_fub11[] U8G_FONT_SECTION("u8g_font_fub11");
1564 extern const u8g_fntpgm_uint8_t u8g_font_fub11r[] U8G_FONT_SECTION("u8g_font_fub11r");
1565 extern const u8g_fntpgm_uint8_t u8g_font_fub11n[] U8G_FONT_SECTION("u8g_font_fub11n");
1566 extern const u8g_fntpgm_uint8_t u8g_font_fub14[] U8G_FONT_SECTION("u8g_font_fub14");
1567 extern const u8g_fntpgm_uint8_t u8g_font_fub14r[] U8G_FONT_SECTION("u8g_font_fub14r");
1568 extern const u8g_fntpgm_uint8_t u8g_font_fub14n[] U8G_FONT_SECTION("u8g_font_fub14n");
1569 extern const u8g_fntpgm_uint8_t u8g_font_fub17[] U8G_FONT_SECTION("u8g_font_fub17");
1570 extern const u8g_fntpgm_uint8_t u8g_font_fub17r[] U8G_FONT_SECTION("u8g_font_fub17r");
1571 extern const u8g_fntpgm_uint8_t u8g_font_fub17n[] U8G_FONT_SECTION("u8g_font_fub17n");
1572 extern const u8g_fntpgm_uint8_t u8g_font_fub20[] U8G_FONT_SECTION("u8g_font_fub20");
1573 extern const u8g_fntpgm_uint8_t u8g_font_fub20r[] U8G_FONT_SECTION("u8g_font_fub20r");
1574 extern const u8g_fntpgm_uint8_t u8g_font_fub20n[] U8G_FONT_SECTION("u8g_font_fub20n");
1575 extern const u8g_fntpgm_uint8_t u8g_font_fub25[] U8G_FONT_SECTION("u8g_font_fub25");
1576 extern const u8g_fntpgm_uint8_t u8g_font_fub25r[] U8G_FONT_SECTION("u8g_font_fub25r");
1577 extern const u8g_fntpgm_uint8_t u8g_font_fub25n[] U8G_FONT_SECTION("u8g_font_fub25n");
1578 extern const u8g_fntpgm_uint8_t u8g_font_fub30[] U8G_FONT_SECTION("u8g_font_fub30");
1579 extern const u8g_fntpgm_uint8_t u8g_font_fub30r[] U8G_FONT_SECTION("u8g_font_fub30r");
1580 extern const u8g_fntpgm_uint8_t u8g_font_fub30n[] U8G_FONT_SECTION("u8g_font_fub30n");
1581 extern const u8g_fntpgm_uint8_t u8g_font_fub35n[] U8G_FONT_SECTION("u8g_font_fub35n");
1582 extern const u8g_fntpgm_uint8_t u8g_font_fub42n[] U8G_FONT_SECTION("u8g_font_fub42n");
1583 extern const u8g_fntpgm_uint8_t u8g_font_fub49n[] U8G_FONT_SECTION("u8g_font_fub49n");
1584 
1585 /*
1586  Free-Universal Regular
1587  r: Reduced char set (codes 32 - 128)
1588  n: Numbers (codes 42 - 57)
1589  no char: Full set (codes 32 - 255)
1590 */
1591 
1592 extern const u8g_fntpgm_uint8_t u8g_font_fur11[] U8G_FONT_SECTION("u8g_font_fur11");
1593 extern const u8g_fntpgm_uint8_t u8g_font_fur11r[] U8G_FONT_SECTION("u8g_font_fur11r");
1594 extern const u8g_fntpgm_uint8_t u8g_font_fur11n[] U8G_FONT_SECTION("u8g_font_fur11n");
1595 extern const u8g_fntpgm_uint8_t u8g_font_fur14[] U8G_FONT_SECTION("u8g_font_fur14");
1596 extern const u8g_fntpgm_uint8_t u8g_font_fur14r[] U8G_FONT_SECTION("u8g_font_fur14r");
1597 extern const u8g_fntpgm_uint8_t u8g_font_fur14n[] U8G_FONT_SECTION("u8g_font_fur14n");
1598 extern const u8g_fntpgm_uint8_t u8g_font_fur17[] U8G_FONT_SECTION("u8g_font_fur17");
1599 extern const u8g_fntpgm_uint8_t u8g_font_fur17r[] U8G_FONT_SECTION("u8g_font_fur17r");
1600 extern const u8g_fntpgm_uint8_t u8g_font_fur17n[] U8G_FONT_SECTION("u8g_font_fur17n");
1601 extern const u8g_fntpgm_uint8_t u8g_font_fur20[] U8G_FONT_SECTION("u8g_font_fur20");
1602 extern const u8g_fntpgm_uint8_t u8g_font_fur20r[] U8G_FONT_SECTION("u8g_font_fur20r");
1603 extern const u8g_fntpgm_uint8_t u8g_font_fur20n[] U8G_FONT_SECTION("u8g_font_fur20n");
1604 extern const u8g_fntpgm_uint8_t u8g_font_fur25[] U8G_FONT_SECTION("u8g_font_fur25");
1605 extern const u8g_fntpgm_uint8_t u8g_font_fur25r[] U8G_FONT_SECTION("u8g_font_fur25r");
1606 extern const u8g_fntpgm_uint8_t u8g_font_fur25n[] U8G_FONT_SECTION("u8g_font_fur25n");
1607 extern const u8g_fntpgm_uint8_t u8g_font_fur30[] U8G_FONT_SECTION("u8g_font_fur30");
1608 extern const u8g_fntpgm_uint8_t u8g_font_fur30r[] U8G_FONT_SECTION("u8g_font_fur30r");
1609 extern const u8g_fntpgm_uint8_t u8g_font_fur30n[] U8G_FONT_SECTION("u8g_font_fur30n");
1610 extern const u8g_fntpgm_uint8_t u8g_font_fur35n[] U8G_FONT_SECTION("u8g_font_fur35n");
1611 extern const u8g_fntpgm_uint8_t u8g_font_fur42n[] U8G_FONT_SECTION("u8g_font_fur42n");
1612 extern const u8g_fntpgm_uint8_t u8g_font_fur49n[] U8G_FONT_SECTION("u8g_font_fur49n");
1613 
1614 /*
1615  Gentium Bold
1616  r: Reduced char set (codes 32 - 128)
1617  n: Numbers (codes 42 - 57)
1618  no char: Full set (codes 32 - 255)
1619 */
1620 
1621 extern const u8g_fntpgm_uint8_t u8g_font_gdb11[] U8G_FONT_SECTION("u8g_font_gdb11");
1622 extern const u8g_fntpgm_uint8_t u8g_font_gdb12[] U8G_FONT_SECTION("u8g_font_gdb12");
1623 extern const u8g_fntpgm_uint8_t u8g_font_gdb14[] U8G_FONT_SECTION("u8g_font_gdb14");
1624 extern const u8g_fntpgm_uint8_t u8g_font_gdb17[] U8G_FONT_SECTION("u8g_font_gdb17");
1625 extern const u8g_fntpgm_uint8_t u8g_font_gdb20[] U8G_FONT_SECTION("u8g_font_gdb20");
1626 extern const u8g_fntpgm_uint8_t u8g_font_gdb25[] U8G_FONT_SECTION("u8g_font_gdb25");
1627 extern const u8g_fntpgm_uint8_t u8g_font_gdb30[] U8G_FONT_SECTION("u8g_font_gdb30");
1628 
1629 extern const u8g_fntpgm_uint8_t u8g_font_gdb11r[] U8G_FONT_SECTION("u8g_font_gdb11r");
1630 extern const u8g_fntpgm_uint8_t u8g_font_gdb12r[] U8G_FONT_SECTION("u8g_font_gdb12r");
1631 extern const u8g_fntpgm_uint8_t u8g_font_gdb14r[] U8G_FONT_SECTION("u8g_font_gdb14r");
1632 extern const u8g_fntpgm_uint8_t u8g_font_gdb17r[] U8G_FONT_SECTION("u8g_font_gdb17r");
1633 extern const u8g_fntpgm_uint8_t u8g_font_gdb20r[] U8G_FONT_SECTION("u8g_font_gdb20r");
1634 extern const u8g_fntpgm_uint8_t u8g_font_gdb25r[] U8G_FONT_SECTION("u8g_font_gdb25r");
1635 extern const u8g_fntpgm_uint8_t u8g_font_gdb30r[] U8G_FONT_SECTION("u8g_font_gdb30r");
1636 
1637 extern const u8g_fntpgm_uint8_t u8g_font_gdb11n[] U8G_FONT_SECTION("u8g_font_gdb11n");
1638 extern const u8g_fntpgm_uint8_t u8g_font_gdb12n[] U8G_FONT_SECTION("u8g_font_gdb12n");
1639 extern const u8g_fntpgm_uint8_t u8g_font_gdb14n[] U8G_FONT_SECTION("u8g_font_gdb14n");
1640 extern const u8g_fntpgm_uint8_t u8g_font_gdb17n[] U8G_FONT_SECTION("u8g_font_gdb17n");
1641 extern const u8g_fntpgm_uint8_t u8g_font_gdb20n[] U8G_FONT_SECTION("u8g_font_gdb20n");
1642 extern const u8g_fntpgm_uint8_t u8g_font_gdb25n[] U8G_FONT_SECTION("u8g_font_gdb25n");
1643 extern const u8g_fntpgm_uint8_t u8g_font_gdb30n[] U8G_FONT_SECTION("u8g_font_gdb30n");
1644 
1645 /*
1646  Gentium Regular
1647  r: Reduced char set (codes 32 - 128)
1648  n: Numbers (codes 42 - 57)
1649  no char: Full set (codes 32 - 255)
1650 */
1651 
1652 extern const u8g_fntpgm_uint8_t u8g_font_gdr9[] U8G_FONT_SECTION("u8g_font_gdr9");
1653 extern const u8g_fntpgm_uint8_t u8g_font_gdr10[] U8G_FONT_SECTION("u8g_font_gdr10");
1654 extern const u8g_fntpgm_uint8_t u8g_font_gdr11[] U8G_FONT_SECTION("u8g_font_gdr11");
1655 extern const u8g_fntpgm_uint8_t u8g_font_gdr12[] U8G_FONT_SECTION("u8g_font_gdr12");
1656 extern const u8g_fntpgm_uint8_t u8g_font_gdr14[] U8G_FONT_SECTION("u8g_font_gdr14");
1657 extern const u8g_fntpgm_uint8_t u8g_font_gdr17[] U8G_FONT_SECTION("u8g_font_gdr17");
1658 extern const u8g_fntpgm_uint8_t u8g_font_gdr20[] U8G_FONT_SECTION("u8g_font_gdr20");
1659 extern const u8g_fntpgm_uint8_t u8g_font_gdr25[] U8G_FONT_SECTION("u8g_font_gdr25");
1660 extern const u8g_fntpgm_uint8_t u8g_font_gdr30[] U8G_FONT_SECTION("u8g_font_gdr30");
1661 
1662 extern const u8g_fntpgm_uint8_t u8g_font_gdr9r[] U8G_FONT_SECTION("u8g_font_gdr9r");
1663 extern const u8g_fntpgm_uint8_t u8g_font_gdr10r[] U8G_FONT_SECTION("u8g_font_gdr10r");
1664 extern const u8g_fntpgm_uint8_t u8g_font_gdr11r[] U8G_FONT_SECTION("u8g_font_gdr11r");
1665 extern const u8g_fntpgm_uint8_t u8g_font_gdr12r[] U8G_FONT_SECTION("u8g_font_gdr12r");
1666 extern const u8g_fntpgm_uint8_t u8g_font_gdr14r[] U8G_FONT_SECTION("u8g_font_gdr14r");
1667 extern const u8g_fntpgm_uint8_t u8g_font_gdr17r[] U8G_FONT_SECTION("u8g_font_gdr17r");
1668 extern const u8g_fntpgm_uint8_t u8g_font_gdr20r[] U8G_FONT_SECTION("u8g_font_gdr20r");
1669 extern const u8g_fntpgm_uint8_t u8g_font_gdr25r[] U8G_FONT_SECTION("u8g_font_gdr25r");
1670 extern const u8g_fntpgm_uint8_t u8g_font_gdr30r[] U8G_FONT_SECTION("u8g_font_gdr30r");
1671 
1672 extern const u8g_fntpgm_uint8_t u8g_font_gdr9n[] U8G_FONT_SECTION("u8g_font_gdr9n");
1673 extern const u8g_fntpgm_uint8_t u8g_font_gdr10n[] U8G_FONT_SECTION("u8g_font_gdr10n");
1674 extern const u8g_fntpgm_uint8_t u8g_font_gdr11n[] U8G_FONT_SECTION("u8g_font_gdr11n");
1675 extern const u8g_fntpgm_uint8_t u8g_font_gdr12n[] U8G_FONT_SECTION("u8g_font_gdr12n");
1676 extern const u8g_fntpgm_uint8_t u8g_font_gdr14n[] U8G_FONT_SECTION("u8g_font_gdr14n");
1677 extern const u8g_fntpgm_uint8_t u8g_font_gdr17n[] U8G_FONT_SECTION("u8g_font_gdr17n");
1678 extern const u8g_fntpgm_uint8_t u8g_font_gdr20n[] U8G_FONT_SECTION("u8g_font_gdr20n");
1679 extern const u8g_fntpgm_uint8_t u8g_font_gdr25n[] U8G_FONT_SECTION("u8g_font_gdr25n");
1680 extern const u8g_fntpgm_uint8_t u8g_font_gdr30n[] U8G_FONT_SECTION("u8g_font_gdr30n");
1681 
1682 /*
1683  Old-Standard Bold
1684  r: Reduced char set (codes 32 - 128)
1685  n: Numbers (codes 42 - 57)
1686  no char: Full set (codes 32 - 255)
1687 */
1688 
1689 extern const u8g_fntpgm_uint8_t u8g_font_osb18[] U8G_FONT_SECTION("u8g_font_osb18");
1690 extern const u8g_fntpgm_uint8_t u8g_font_osb21[] U8G_FONT_SECTION("u8g_font_osb21");
1691 extern const u8g_fntpgm_uint8_t u8g_font_osb26[] U8G_FONT_SECTION("u8g_font_osb26");
1692 extern const u8g_fntpgm_uint8_t u8g_font_osb29[] U8G_FONT_SECTION("u8g_font_osb29");
1693 extern const u8g_fntpgm_uint8_t u8g_font_osb35[] U8G_FONT_SECTION("u8g_font_osb35");
1694 
1695 extern const u8g_fntpgm_uint8_t u8g_font_osb18r[] U8G_FONT_SECTION("u8g_font_osb18r");
1696 extern const u8g_fntpgm_uint8_t u8g_font_osb21r[] U8G_FONT_SECTION("u8g_font_osb21r");
1697 extern const u8g_fntpgm_uint8_t u8g_font_osb26r[] U8G_FONT_SECTION("u8g_font_osb26r");
1698 extern const u8g_fntpgm_uint8_t u8g_font_osb29r[] U8G_FONT_SECTION("u8g_font_osb29r");
1699 extern const u8g_fntpgm_uint8_t u8g_font_osb35r[] U8G_FONT_SECTION("u8g_font_osb35r");
1700 
1701 extern const u8g_fntpgm_uint8_t u8g_font_osb18n[] U8G_FONT_SECTION("u8g_font_osb18n");
1702 extern const u8g_fntpgm_uint8_t u8g_font_osb21n[] U8G_FONT_SECTION("u8g_font_osb21n");
1703 extern const u8g_fntpgm_uint8_t u8g_font_osb26n[] U8G_FONT_SECTION("u8g_font_osb26n");
1704 extern const u8g_fntpgm_uint8_t u8g_font_osb29n[] U8G_FONT_SECTION("u8g_font_osb29n");
1705 extern const u8g_fntpgm_uint8_t u8g_font_osb35n[] U8G_FONT_SECTION("u8g_font_osb35n");
1706 
1707 /*
1708  Old-Standard Regular
1709  r: Reduced char set (codes 32 - 128)
1710  n: Numbers (codes 42 - 57)
1711  no char: Full set (codes 32 - 255)
1712 */
1713 
1714 extern const u8g_fntpgm_uint8_t u8g_font_osr18[] U8G_FONT_SECTION("u8g_font_osr18");
1715 extern const u8g_fntpgm_uint8_t u8g_font_osr21[] U8G_FONT_SECTION("u8g_font_osr21");
1716 extern const u8g_fntpgm_uint8_t u8g_font_osr26[] U8G_FONT_SECTION("u8g_font_osr26");
1717 extern const u8g_fntpgm_uint8_t u8g_font_osr29[] U8G_FONT_SECTION("u8g_font_osr29");
1718 extern const u8g_fntpgm_uint8_t u8g_font_osr35[] U8G_FONT_SECTION("u8g_font_osr35");
1719 
1720 extern const u8g_fntpgm_uint8_t u8g_font_osr18r[] U8G_FONT_SECTION("u8g_font_osr18r");
1721 extern const u8g_fntpgm_uint8_t u8g_font_osr21r[] U8G_FONT_SECTION("u8g_font_osr21r");
1722 extern const u8g_fntpgm_uint8_t u8g_font_osr26r[] U8G_FONT_SECTION("u8g_font_osr26r");
1723 extern const u8g_fntpgm_uint8_t u8g_font_osr29r[] U8G_FONT_SECTION("u8g_font_osr29r");
1724 extern const u8g_fntpgm_uint8_t u8g_font_osr35r[] U8G_FONT_SECTION("u8g_font_osr35r");
1725 
1726 extern const u8g_fntpgm_uint8_t u8g_font_osr18n[] U8G_FONT_SECTION("u8g_font_osr18n");
1727 extern const u8g_fntpgm_uint8_t u8g_font_osr21n[] U8G_FONT_SECTION("u8g_font_osr21n");
1728 extern const u8g_fntpgm_uint8_t u8g_font_osr26n[] U8G_FONT_SECTION("u8g_font_osr26n");
1729 extern const u8g_fntpgm_uint8_t u8g_font_osr29n[] U8G_FONT_SECTION("u8g_font_osr29n");
1730 extern const u8g_fntpgm_uint8_t u8g_font_osr35n[] U8G_FONT_SECTION("u8g_font_osr35n");
1731 
1732 //extern const u8g_fntpgm_uint8_t u8g_font_osr41[] U8G_FONT_SECTION("u8g_font_osr41");
1733 
1734 /* GNU unifont */
1735 
1736 extern const u8g_fntpgm_uint8_t u8g_font_unifont_18_19[] U8G_FONT_SECTION("u8g_font_unifont_18_19");
1737 extern const u8g_fntpgm_uint8_t u8g_font_unifont_72_73[] U8G_FONT_SECTION("u8g_font_unifont_72_73");
1738 extern const u8g_fntpgm_uint8_t u8g_font_unifont_67_75[] U8G_FONT_SECTION("u8g_font_unifont_67_75");
1739 extern const u8g_fntpgm_uint8_t u8g_font_unifont_76[] U8G_FONT_SECTION("u8g_font_unifont_76");
1740 extern const u8g_fntpgm_uint8_t u8g_font_unifont_77[] U8G_FONT_SECTION("u8g_font_unifont_77");
1741 extern const u8g_fntpgm_uint8_t u8g_font_unifont_78_79[] U8G_FONT_SECTION("u8g_font_unifont_78_79");
1742 extern const u8g_fntpgm_uint8_t u8g_font_unifont_86[] U8G_FONT_SECTION("u8g_font_unifont_86");
1743 extern const u8g_fntpgm_uint8_t u8g_font_unifont[] U8G_FONT_SECTION("u8g_font_unifont");
1744 extern const u8g_fntpgm_uint8_t u8g_font_unifontr[] U8G_FONT_SECTION("u8g_font_unifontr");
1745 extern const u8g_fntpgm_uint8_t u8g_font_unifont_0_8[] U8G_FONT_SECTION("u8g_font_unifont_0_8");
1746 extern const u8g_fntpgm_uint8_t u8g_font_unifont_2_3[] U8G_FONT_SECTION("u8g_font_unifont_2_3");
1747 extern const u8g_fntpgm_uint8_t u8g_font_unifont_4_5[] U8G_FONT_SECTION("u8g_font_unifont_4_5");
1748 extern const u8g_fntpgm_uint8_t u8g_font_unifont_8_9[] U8G_FONT_SECTION("u8g_font_unifont_8_9");
1749 extern const u8g_fntpgm_uint8_t u8g_font_unifont_12_13[] U8G_FONT_SECTION("u8g_font_unifont_12_13");
1750 
1751 
1752 /* 04b fonts */
1753 
1754 extern const u8g_fntpgm_uint8_t u8g_font_04b_03b[] U8G_FONT_SECTION("u8g_font_04b_03b");
1755 extern const u8g_fntpgm_uint8_t u8g_font_04b_03bn[] U8G_FONT_SECTION("u8g_font_04b_03bn");
1756 extern const u8g_fntpgm_uint8_t u8g_font_04b_03br[] U8G_FONT_SECTION("u8g_font_04b_03br");
1757 extern const u8g_fntpgm_uint8_t u8g_font_04b_03[] U8G_FONT_SECTION("u8g_font_04b_03");
1758 extern const u8g_fntpgm_uint8_t u8g_font_04b_03n[] U8G_FONT_SECTION("u8g_font_04b_03n");
1759 extern const u8g_fntpgm_uint8_t u8g_font_04b_03r[] U8G_FONT_SECTION("u8g_font_04b_03r");
1760 extern const u8g_fntpgm_uint8_t u8g_font_04b_24[] U8G_FONT_SECTION("u8g_font_04b_24");
1761 extern const u8g_fntpgm_uint8_t u8g_font_04b_24n[] U8G_FONT_SECTION("u8g_font_04b_24n");
1762 extern const u8g_fntpgm_uint8_t u8g_font_04b_24r[] U8G_FONT_SECTION("u8g_font_04b_24r");
1763 
1764 /* orgdot fonts */
1765 
1766 extern const u8g_fntpgm_uint8_t u8g_font_orgv01[] U8G_FONT_SECTION("u8g_font_orgv01");
1767 extern const u8g_fntpgm_uint8_t u8g_font_orgv01r[] U8G_FONT_SECTION("u8g_font_orgv01r");
1768 extern const u8g_fntpgm_uint8_t u8g_font_orgv01n[] U8G_FONT_SECTION("u8g_font_orgv01n");
1769 
1770 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0[] U8G_FONT_SECTION("u8g_font_fixed_v0");
1771 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0r[] U8G_FONT_SECTION("u8g_font_fixed_v0r");
1772 extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0n[] U8G_FONT_SECTION("u8g_font_fixed_v0n");
1773 
1774 extern const u8g_fntpgm_uint8_t u8g_font_tpssb[] U8G_FONT_SECTION("u8g_font_tpssb");
1775 extern const u8g_fntpgm_uint8_t u8g_font_tpssbr[] U8G_FONT_SECTION("u8g_font_tpssbr");
1776 extern const u8g_fntpgm_uint8_t u8g_font_tpssbn[] U8G_FONT_SECTION("u8g_font_tpssbn");
1777 
1778 extern const u8g_fntpgm_uint8_t u8g_font_tpss[] U8G_FONT_SECTION("u8g_font_tpss");
1779 extern const u8g_fntpgm_uint8_t u8g_font_tpssr[] U8G_FONT_SECTION("u8g_font_tpssr");
1780 extern const u8g_fntpgm_uint8_t u8g_font_tpssn[] U8G_FONT_SECTION("u8g_font_tpssn");
1781 
1782 /* contributed */
1783 
1784 extern const u8g_fntpgm_uint8_t u8g_font_freedoomr25n[] U8G_FONT_SECTION("u8g_font_freedoomr25n");
1785 extern const u8g_fntpgm_uint8_t u8g_font_freedoomr10r[] U8G_FONT_SECTION("u8g_font_freedoomr10r");
1786 
1787 /* adobe X11 */
1788 extern const u8g_fntpgm_uint8_t u8g_font_courB08[] U8G_FONT_SECTION("u8g_font_courB08");
1789 extern const u8g_fntpgm_uint8_t u8g_font_courB08r[] U8G_FONT_SECTION("u8g_font_courB08r");
1790 extern const u8g_fntpgm_uint8_t u8g_font_courB10[] U8G_FONT_SECTION("u8g_font_courB10");
1791 extern const u8g_fntpgm_uint8_t u8g_font_courB10r[] U8G_FONT_SECTION("u8g_font_courB10r");
1792 extern const u8g_fntpgm_uint8_t u8g_font_courB12[] U8G_FONT_SECTION("u8g_font_courB12");
1793 extern const u8g_fntpgm_uint8_t u8g_font_courB12r[] U8G_FONT_SECTION("u8g_font_courB12r");
1794 extern const u8g_fntpgm_uint8_t u8g_font_courB14[] U8G_FONT_SECTION("u8g_font_courB14");
1795 extern const u8g_fntpgm_uint8_t u8g_font_courB14r[] U8G_FONT_SECTION("u8g_font_courB14r");
1796 extern const u8g_fntpgm_uint8_t u8g_font_courB18[] U8G_FONT_SECTION("u8g_font_courB18");
1797 extern const u8g_fntpgm_uint8_t u8g_font_courB18r[] U8G_FONT_SECTION("u8g_font_courB18r");
1798 extern const u8g_fntpgm_uint8_t u8g_font_courB24[] U8G_FONT_SECTION("u8g_font_courB24");
1799 extern const u8g_fntpgm_uint8_t u8g_font_courB24r[] U8G_FONT_SECTION("u8g_font_courB24r");
1800 extern const u8g_fntpgm_uint8_t u8g_font_courB24n[] U8G_FONT_SECTION("u8g_font_courB24n");
1801 
1802 extern const u8g_fntpgm_uint8_t u8g_font_courR08[] U8G_FONT_SECTION("u8g_font_courR08");
1803 extern const u8g_fntpgm_uint8_t u8g_font_courR08r[] U8G_FONT_SECTION("u8g_font_courR08r");
1804 extern const u8g_fntpgm_uint8_t u8g_font_courR10[] U8G_FONT_SECTION("u8g_font_courR10");
1805 extern const u8g_fntpgm_uint8_t u8g_font_courR10r[] U8G_FONT_SECTION("u8g_font_courR10r");
1806 extern const u8g_fntpgm_uint8_t u8g_font_courR12[] U8G_FONT_SECTION("u8g_font_courR12");
1807 extern const u8g_fntpgm_uint8_t u8g_font_courR12r[] U8G_FONT_SECTION("u8g_font_courR12r");
1808 extern const u8g_fntpgm_uint8_t u8g_font_courR14[] U8G_FONT_SECTION("u8g_font_courR14");
1809 extern const u8g_fntpgm_uint8_t u8g_font_courR14r[] U8G_FONT_SECTION("u8g_font_courR14r");
1810 extern const u8g_fntpgm_uint8_t u8g_font_courR18[] U8G_FONT_SECTION("u8g_font_courR18");
1811 extern const u8g_fntpgm_uint8_t u8g_font_courR18r[] U8G_FONT_SECTION("u8g_font_courR18r");
1812 extern const u8g_fntpgm_uint8_t u8g_font_courR24[] U8G_FONT_SECTION("u8g_font_courR24");
1813 extern const u8g_fntpgm_uint8_t u8g_font_courR24r[] U8G_FONT_SECTION("u8g_font_courR24r");
1814 extern const u8g_fntpgm_uint8_t u8g_font_courR24n[] U8G_FONT_SECTION("u8g_font_courR24n");
1815 
1816 extern const u8g_fntpgm_uint8_t u8g_font_helvB08[] U8G_FONT_SECTION("u8g_font_helvB08");
1817 extern const u8g_fntpgm_uint8_t u8g_font_helvB08r[] U8G_FONT_SECTION("u8g_font_helvB08r");
1818 extern const u8g_fntpgm_uint8_t u8g_font_helvB10[] U8G_FONT_SECTION("u8g_font_helvB10");
1819 extern const u8g_fntpgm_uint8_t u8g_font_helvB10r[] U8G_FONT_SECTION("u8g_font_helvB10r");
1820 extern const u8g_fntpgm_uint8_t u8g_font_helvB12[] U8G_FONT_SECTION("u8g_font_helvB12");
1821 extern const u8g_fntpgm_uint8_t u8g_font_helvB12r[] U8G_FONT_SECTION("u8g_font_helvB12r");
1822 extern const u8g_fntpgm_uint8_t u8g_font_helvB14[] U8G_FONT_SECTION("u8g_font_helvB14");
1823 extern const u8g_fntpgm_uint8_t u8g_font_helvB14r[] U8G_FONT_SECTION("u8g_font_helvB14r");
1824 extern const u8g_fntpgm_uint8_t u8g_font_helvB18[] U8G_FONT_SECTION("u8g_font_helvB18");
1825 extern const u8g_fntpgm_uint8_t u8g_font_helvB18r[] U8G_FONT_SECTION("u8g_font_helvB18r");
1826 extern const u8g_fntpgm_uint8_t u8g_font_helvB24[] U8G_FONT_SECTION("u8g_font_helvB24");
1827 extern const u8g_fntpgm_uint8_t u8g_font_helvB24r[] U8G_FONT_SECTION("u8g_font_helvB24r");
1828 extern const u8g_fntpgm_uint8_t u8g_font_helvB24n[] U8G_FONT_SECTION("u8g_font_helvB24n");
1829 
1830 extern const u8g_fntpgm_uint8_t u8g_font_helvR08[] U8G_FONT_SECTION("u8g_font_helvR08");
1831 extern const u8g_fntpgm_uint8_t u8g_font_helvR08r[] U8G_FONT_SECTION("u8g_font_helvR08r");
1832 extern const u8g_fntpgm_uint8_t u8g_font_helvR10[] U8G_FONT_SECTION("u8g_font_helvR10");
1833 extern const u8g_fntpgm_uint8_t u8g_font_helvR10r[] U8G_FONT_SECTION("u8g_font_helvR10r");
1834 extern const u8g_fntpgm_uint8_t u8g_font_helvR12[] U8G_FONT_SECTION("u8g_font_helvR12");
1835 extern const u8g_fntpgm_uint8_t u8g_font_helvR12r[] U8G_FONT_SECTION("u8g_font_helvR12r");
1836 extern const u8g_fntpgm_uint8_t u8g_font_helvR14[] U8G_FONT_SECTION("u8g_font_helvR14");
1837 extern const u8g_fntpgm_uint8_t u8g_font_helvR14r[] U8G_FONT_SECTION("u8g_font_helvR14r");
1838 extern const u8g_fntpgm_uint8_t u8g_font_helvR18[] U8G_FONT_SECTION("u8g_font_helvR18");
1839 extern const u8g_fntpgm_uint8_t u8g_font_helvR18r[] U8G_FONT_SECTION("u8g_font_helvR18r");
1840 extern const u8g_fntpgm_uint8_t u8g_font_helvR24[] U8G_FONT_SECTION("u8g_font_helvR24");
1841 extern const u8g_fntpgm_uint8_t u8g_font_helvR24r[] U8G_FONT_SECTION("u8g_font_helvR24r");
1842 extern const u8g_fntpgm_uint8_t u8g_font_helvR24n[] U8G_FONT_SECTION("u8g_font_helvR24n");
1843 
1844 extern const u8g_fntpgm_uint8_t u8g_font_ncenB08[] U8G_FONT_SECTION("u8g_font_ncenB08");
1845 extern const u8g_fntpgm_uint8_t u8g_font_ncenB08r[] U8G_FONT_SECTION("u8g_font_ncenB08r");
1846 extern const u8g_fntpgm_uint8_t u8g_font_ncenB10[] U8G_FONT_SECTION("u8g_font_ncenB10");
1847 extern const u8g_fntpgm_uint8_t u8g_font_ncenB10r[] U8G_FONT_SECTION("u8g_font_ncenB10r");
1848 extern const u8g_fntpgm_uint8_t u8g_font_ncenB12[] U8G_FONT_SECTION("u8g_font_ncenB12");
1849 extern const u8g_fntpgm_uint8_t u8g_font_ncenB12r[] U8G_FONT_SECTION("u8g_font_ncenB12r");
1850 extern const u8g_fntpgm_uint8_t u8g_font_ncenB14[] U8G_FONT_SECTION("u8g_font_ncenB14");
1851 extern const u8g_fntpgm_uint8_t u8g_font_ncenB14r[] U8G_FONT_SECTION("u8g_font_ncenB14r");
1852 extern const u8g_fntpgm_uint8_t u8g_font_ncenB18[] U8G_FONT_SECTION("u8g_font_ncenB18");
1853 extern const u8g_fntpgm_uint8_t u8g_font_ncenB18r[] U8G_FONT_SECTION("u8g_font_ncenB18r");
1854 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24[] U8G_FONT_SECTION("u8g_font_ncenB24");
1855 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24r[] U8G_FONT_SECTION("u8g_font_ncenB24r");
1856 extern const u8g_fntpgm_uint8_t u8g_font_ncenB24n[] U8G_FONT_SECTION("u8g_font_ncenB24n");
1857 
1858 extern const u8g_fntpgm_uint8_t u8g_font_ncenR08[] U8G_FONT_SECTION("u8g_font_ncenR08");
1859 extern const u8g_fntpgm_uint8_t u8g_font_ncenR08r[] U8G_FONT_SECTION("u8g_font_ncenR08r");
1860 extern const u8g_fntpgm_uint8_t u8g_font_ncenR10[] U8G_FONT_SECTION("u8g_font_ncenR10");
1861 extern const u8g_fntpgm_uint8_t u8g_font_ncenR10r[] U8G_FONT_SECTION("u8g_font_ncenR10r");
1862 extern const u8g_fntpgm_uint8_t u8g_font_ncenR12[] U8G_FONT_SECTION("u8g_font_ncenR12");
1863 extern const u8g_fntpgm_uint8_t u8g_font_ncenR12r[] U8G_FONT_SECTION("u8g_font_ncenR12r");
1864 extern const u8g_fntpgm_uint8_t u8g_font_ncenR14[] U8G_FONT_SECTION("u8g_font_ncenR14");
1865 extern const u8g_fntpgm_uint8_t u8g_font_ncenR14r[] U8G_FONT_SECTION("u8g_font_ncenR14r");
1866 extern const u8g_fntpgm_uint8_t u8g_font_ncenR18[] U8G_FONT_SECTION("u8g_font_ncenR18");
1867 extern const u8g_fntpgm_uint8_t u8g_font_ncenR18r[] U8G_FONT_SECTION("u8g_font_ncenR18r");
1868 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24[] U8G_FONT_SECTION("u8g_font_ncenR24");
1869 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24r[] U8G_FONT_SECTION("u8g_font_ncenR24r");
1870 extern const u8g_fntpgm_uint8_t u8g_font_ncenR24n[] U8G_FONT_SECTION("u8g_font_ncenR24n");
1871 
1872 extern const u8g_fntpgm_uint8_t u8g_font_symb08[] U8G_FONT_SECTION("u8g_font_symb08");
1873 extern const u8g_fntpgm_uint8_t u8g_font_symb08r[] U8G_FONT_SECTION("u8g_font_symb08r");
1874 extern const u8g_fntpgm_uint8_t u8g_font_symb10[] U8G_FONT_SECTION("u8g_font_symb10");
1875 extern const u8g_fntpgm_uint8_t u8g_font_symb10r[] U8G_FONT_SECTION("u8g_font_symb10r");
1876 extern const u8g_fntpgm_uint8_t u8g_font_symb12[] U8G_FONT_SECTION("u8g_font_symb12");
1877 extern const u8g_fntpgm_uint8_t u8g_font_symb12r[] U8G_FONT_SECTION("u8g_font_symb12r");
1878 extern const u8g_fntpgm_uint8_t u8g_font_symb14[] U8G_FONT_SECTION("u8g_font_symb14");
1879 extern const u8g_fntpgm_uint8_t u8g_font_symb14r[] U8G_FONT_SECTION("u8g_font_symb14r");
1880 extern const u8g_fntpgm_uint8_t u8g_font_symb18[] U8G_FONT_SECTION("u8g_font_symb18");
1881 extern const u8g_fntpgm_uint8_t u8g_font_symb18r[] U8G_FONT_SECTION("u8g_font_symb18r");
1882 extern const u8g_fntpgm_uint8_t u8g_font_symb24[] U8G_FONT_SECTION("u8g_font_symb24");
1883 extern const u8g_fntpgm_uint8_t u8g_font_symb24r[] U8G_FONT_SECTION("u8g_font_symb24r");
1884 
1885 extern const u8g_fntpgm_uint8_t u8g_font_timB08[] U8G_FONT_SECTION("u8g_font_timB08");
1886 extern const u8g_fntpgm_uint8_t u8g_font_timB08r[] U8G_FONT_SECTION("u8g_font_timB08r");
1887 extern const u8g_fntpgm_uint8_t u8g_font_timB10[] U8G_FONT_SECTION("u8g_font_timB10");
1888 extern const u8g_fntpgm_uint8_t u8g_font_timB10r[] U8G_FONT_SECTION("u8g_font_timB10r");
1889 extern const u8g_fntpgm_uint8_t u8g_font_timB12[] U8G_FONT_SECTION("u8g_font_timB12");
1890 extern const u8g_fntpgm_uint8_t u8g_font_timB12r[] U8G_FONT_SECTION("u8g_font_timB12r");
1891 extern const u8g_fntpgm_uint8_t u8g_font_timB14[] U8G_FONT_SECTION("u8g_font_timB14");
1892 extern const u8g_fntpgm_uint8_t u8g_font_timB14r[] U8G_FONT_SECTION("u8g_font_timB14r");
1893 extern const u8g_fntpgm_uint8_t u8g_font_timB18[] U8G_FONT_SECTION("u8g_font_timB18");
1894 extern const u8g_fntpgm_uint8_t u8g_font_timB18r[] U8G_FONT_SECTION("u8g_font_timB18r");
1895 extern const u8g_fntpgm_uint8_t u8g_font_timB24[] U8G_FONT_SECTION("u8g_font_timB24");
1896 extern const u8g_fntpgm_uint8_t u8g_font_timB24r[] U8G_FONT_SECTION("u8g_font_timB24r");
1897 extern const u8g_fntpgm_uint8_t u8g_font_timB24n[] U8G_FONT_SECTION("u8g_font_timB24n");
1898 
1899 extern const u8g_fntpgm_uint8_t u8g_font_timR08[] U8G_FONT_SECTION("u8g_font_timR08");
1900 extern const u8g_fntpgm_uint8_t u8g_font_timR08r[] U8G_FONT_SECTION("u8g_font_timR08r");
1901 extern const u8g_fntpgm_uint8_t u8g_font_timR10[] U8G_FONT_SECTION("u8g_font_timR10");
1902 extern const u8g_fntpgm_uint8_t u8g_font_timR10r[] U8G_FONT_SECTION("u8g_font_timR10r");
1903 extern const u8g_fntpgm_uint8_t u8g_font_timR12[] U8G_FONT_SECTION("u8g_font_timR12");
1904 extern const u8g_fntpgm_uint8_t u8g_font_timR12r[] U8G_FONT_SECTION("u8g_font_timR12r");
1905 extern const u8g_fntpgm_uint8_t u8g_font_timR14[] U8G_FONT_SECTION("u8g_font_timR14");
1906 extern const u8g_fntpgm_uint8_t u8g_font_timR14r[] U8G_FONT_SECTION("u8g_font_timR14r");
1907 extern const u8g_fntpgm_uint8_t u8g_font_timR18[] U8G_FONT_SECTION("u8g_font_timR18");
1908 extern const u8g_fntpgm_uint8_t u8g_font_timR18r[] U8G_FONT_SECTION("u8g_font_timR18r");
1909 extern const u8g_fntpgm_uint8_t u8g_font_timR24[] U8G_FONT_SECTION("u8g_font_timR24");
1910 extern const u8g_fntpgm_uint8_t u8g_font_timR24r[] U8G_FONT_SECTION("u8g_font_timR24r");
1911 extern const u8g_fntpgm_uint8_t u8g_font_timR24n[] U8G_FONT_SECTION("u8g_font_timR24n");
1912 
1913 /* fontstruct */
1914 
1915 extern const u8g_fntpgm_uint8_t u8g_font_p01type[] U8G_FONT_SECTION("u8g_font_p01type");
1916 extern const u8g_fntpgm_uint8_t u8g_font_p01typer[] U8G_FONT_SECTION("u8g_font_p01typer");
1917 extern const u8g_fntpgm_uint8_t u8g_font_p01typen[] U8G_FONT_SECTION("u8g_font_p01typen");
1918 
1919 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternate[] U8G_FONT_SECTION("u8g_font_lucasfont_alternate");
1920 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternater[] U8G_FONT_SECTION("u8g_font_lucasfont_alternater");
1921 extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternaten[] U8G_FONT_SECTION("u8g_font_lucasfont_alternaten");
1922 
1923 extern const u8g_fntpgm_uint8_t u8g_font_chikita[] U8G_FONT_SECTION("u8g_font_chikita");
1924 extern const u8g_fntpgm_uint8_t u8g_font_chikitar[] U8G_FONT_SECTION("u8g_font_chikitar");
1925 extern const u8g_fntpgm_uint8_t u8g_font_chikitan[] U8G_FONT_SECTION("u8g_font_chikitan");
1926 
1927 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micro[] U8G_FONT_SECTION("u8g_font_pixelle_micro");
1928 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micror[] U8G_FONT_SECTION("u8g_font_pixelle_micror");
1929 extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micron[] U8G_FONT_SECTION("u8g_font_pixelle_micron");
1930 
1931 extern const u8g_fntpgm_uint8_t u8g_font_trixel_square[] U8G_FONT_SECTION("u8g_font_trixel_square");
1932 extern const u8g_fntpgm_uint8_t u8g_font_trixel_squarer[] U8G_FONT_SECTION("u8g_font_trixel_squarer");
1933 extern const u8g_fntpgm_uint8_t u8g_font_trixel_squaren[] U8G_FONT_SECTION("u8g_font_trixel_squaren");
1934 
1935 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niro[] U8G_FONT_SECTION("u8g_font_robot_de_niro");
1936 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niror[] U8G_FONT_SECTION("u8g_font_robot_de_niror");
1937 extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niron[] U8G_FONT_SECTION("u8g_font_robot_de_niron");
1938 
1939 extern const u8g_fntpgm_uint8_t u8g_font_baby[] U8G_FONT_SECTION("u8g_font_baby");
1940 extern const u8g_fntpgm_uint8_t u8g_font_babyr[] U8G_FONT_SECTION("u8g_font_babyr");
1941 extern const u8g_fntpgm_uint8_t u8g_font_babyn[] U8G_FONT_SECTION("u8g_font_babyn");
1942 
1943 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07[] U8G_FONT_SECTION("u8g_font_blipfest_07");
1944 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07r[] U8G_FONT_SECTION("u8g_font_blipfest_07r");
1945 extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07n[] U8G_FONT_SECTION("u8g_font_blipfest_07n");
1946 
1947 
1948 
1949 #ifdef __cplusplus
1950 }
1951 #endif
1952 
1953 #endif /* _U8G_H */
1954 
1955 /*
1956  Fontname: -Misc-Fixed-Medium-R-Normal--7-70-75-75-C-50-ISO10646-1
1957  Copyright: Public domain font. Share and enjoy.
1958  Capital A Height: 6, '1' Height: 6
1959  Calculated Max Values w= 7 h= 8 x= 4 y= 5 dx= 9 dy= 0 ascent= 8 len= 8
1960  Font Bounding box w= 5 h= 7 x= 0 y=-1
1961  Calculated Min Values x= 0 y=-1 dx= 0 dy= 0
1962  Pure Font ascent = 6 descent=-1
1963  X Font ascent = 6 descent=-1
1964  Max Font ascent = 8 descent=-1
1965 */
1966 const u8g_fntpgm_uint8_t repetier_5x7[2405] U8G_FONT_SECTION("repetier_5x7") = {
1967  0,5,7,0,255,6,2,72,3,186,0,255,255,8,255,6,
1968  255,5,5,5,5,0,0,168,0,136,0,168,5,8,8,6,
1969  0,0,8,8,8,40,72,248,64,32,3,3,3,6,1,4,
1970  64,160,64,5,5,5,6,0,0,248,248,248,248,248,5,5,
1971  5,6,0,0,248,136,136,136,248,5,8,8,6,0,0,32,
1972  80,80,80,112,248,248,112,7,5,5,9,0,0,28,254,130,
1973  130,254,5,8,8,6,0,0,136,80,32,136,32,80,136,136,
1974  6,8,8,6,0,0,72,144,72,252,252,120,48,48,6,8,
1975  8,6,0,0,36,72,36,252,252,120,48,48,6,5,5,6,
1976  0,0,252,252,120,48,48,6,2,2,6,0,0,252,252,6,
1977  6,6,6,0,0,72,144,72,144,252,252,6,6,6,6,0,
1978  0,36,72,36,72,252,252,7,7,7,7,0,0,130,68,56,
1979  40,56,68,130,7,7,7,7,0,0,16,16,56,238,56,16,
1980  16,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1981  255,0,0,0,5,4,0,1,6,6,5,2,0,128,128,128,
1982  128,0,128,3,3,3,5,1,3,160,160,160,5,5,5,5,
1983  0,0,80,248,80,248,80,5,5,5,5,0,0,112,160,112,
1984  40,112,4,6,6,5,0,0,128,144,32,64,144,16,4,5,
1985  5,5,0,0,64,160,64,160,80,1,3,3,5,2,3,128,
1986  128,128,2,6,6,5,1,0,64,128,128,128,128,64,2,6,
1987  6,5,1,0,128,64,64,64,64,128,3,5,5,5,1,0,
1988  160,64,224,64,160,5,5,5,5,0,0,32,32,248,32,32,
1989  3,3,3,5,1,255,96,64,128,4,1,1,5,0,2,240,
1990  2,2,2,5,1,0,192,192,4,4,4,5,0,1,16,32,
1991  64,128,3,6,6,5,1,0,64,160,160,160,160,64,3,6,
1992  6,5,1,0,64,192,64,64,64,224,4,6,6,5,0,0,
1993  96,144,16,32,64,240,4,6,6,5,0,0,240,16,96,16,
1994  144,96,4,6,6,5,0,0,32,96,160,240,32,32,4,6,
1995  6,5,0,0,240,128,224,16,144,96,4,6,6,5,0,0,
1996  96,128,224,144,144,96,4,6,6,5,0,0,240,16,32,32,
1997  64,64,4,6,6,5,0,0,96,144,96,144,144,96,4,6,
1998  6,5,0,0,96,144,144,112,16,96,2,5,5,5,1,0,
1999  192,192,0,192,192,3,6,6,5,0,255,96,96,0,96,64,
2000  128,3,5,5,5,1,0,32,64,128,64,32,4,3,3,5,
2001  0,1,240,0,240,3,5,5,5,1,0,128,64,32,64,128,
2002  3,6,6,5,1,0,64,160,32,64,0,64,4,6,6,5,
2003  0,0,96,144,176,176,128,96,4,6,6,5,0,0,96,144,
2004  144,240,144,144,4,6,6,5,0,0,224,144,224,144,144,224,
2005  4,6,6,5,0,0,96,144,128,128,144,96,4,6,6,5,
2006  0,0,224,144,144,144,144,224,4,6,6,5,0,0,240,128,
2007  224,128,128,240,4,6,6,5,0,0,240,128,224,128,128,128,
2008  4,6,6,5,0,0,96,144,128,176,144,112,4,6,6,5,
2009  0,0,144,144,240,144,144,144,3,6,6,5,1,0,224,64,
2010  64,64,64,224,4,6,6,5,0,0,16,16,16,16,144,96,
2011  4,6,6,5,0,0,144,160,192,192,160,144,4,6,6,5,
2012  0,0,128,128,128,128,128,240,4,6,6,5,0,0,144,240,
2013  240,144,144,144,4,6,6,5,0,0,144,208,208,176,176,144,
2014  4,6,6,5,0,0,96,144,144,144,144,96,4,6,6,5,
2015  0,0,224,144,144,224,128,128,4,7,7,5,0,255,96,144,
2016  144,144,208,96,16,4,6,6,5,0,0,224,144,144,224,160,
2017  144,4,6,6,5,0,0,96,144,64,32,144,96,3,6,6,
2018  5,1,0,224,64,64,64,64,64,4,6,6,5,0,0,144,
2019  144,144,144,144,96,4,6,6,5,0,0,144,144,144,144,96,
2020  96,4,6,6,5,0,0,144,144,144,240,240,144,4,6,6,
2021  5,0,0,144,144,96,96,144,144,3,6,6,5,1,0,160,
2022  160,160,64,64,64,4,6,6,5,0,0,240,16,32,64,128,
2023  240,3,6,6,5,1,0,224,128,128,128,128,224,4,4,4,
2024  5,0,1,128,64,32,16,3,6,6,5,1,0,224,32,32,
2025  32,32,224,3,2,2,5,1,4,64,160,4,1,1,5,0,
2026  0,240,2,2,2,5,1,4,128,64,4,4,4,5,0,0,
2027  112,144,176,80,4,6,6,5,0,0,128,128,224,144,144,224,
2028  3,4,4,5,0,0,96,128,128,96,4,6,6,5,0,0,
2029  16,16,112,144,144,112,4,4,4,5,0,0,96,176,192,96,
2030  4,6,6,5,0,0,32,80,64,224,64,64,4,5,5,5,
2031  0,255,112,144,96,128,112,4,6,6,5,0,0,128,128,224,
2032  144,144,144,3,6,6,5,1,0,64,0,192,64,64,224,3,
2033  7,7,5,1,255,32,0,32,32,32,160,64,4,6,6,5,
2034  0,0,128,128,160,192,160,144,3,6,6,5,1,0,192,64,
2035  64,64,64,224,4,4,4,5,0,0,160,240,144,144,4,4,
2036  4,5,0,0,224,144,144,144,4,4,4,5,0,0,96,144,
2037  144,96,4,5,5,5,0,255,224,144,144,224,128,4,5,5,
2038  5,0,255,112,144,144,112,16,4,4,4,5,0,0,224,144,
2039  128,128,4,4,4,5,0,0,112,192,48,224,4,6,6,5,
2040  0,0,64,64,224,64,64,48,4,4,4,5,0,0,144,144,
2041  144,112,3,4,4,5,1,0,160,160,160,64,4,4,4,5,
2042  0,0,144,144,240,240,4,4,4,5,0,0,144,96,96,144,
2043  4,5,5,5,0,255,144,144,80,32,64,4,4,4,5,0,
2044  0,240,32,64,240,3,6,6,5,1,0,32,64,192,64,64,
2045  32,1,6,6,5,2,0,128,128,128,128,128,128,3,6,6,
2046  5,1,0,128,64,96,64,64,128,4,2,2,5,0,4,80,
2047  160,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
2048  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
2049  255,255,0,0,0,5,4,0,1,6,6,5,2,0,128,0,
2050  128,128,128,128,4,6,6,5,0,255,32,112,160,160,112,32,
2051  4,5,5,5,0,0,48,64,224,64,176,5,5,5,5,0,
2052  0,136,112,80,112,136,3,6,6,5,1,0,160,160,64,224,
2053  64,64,1,5,5,5,2,0,128,128,0,128,128,3,7,7,
2054  5,1,255,96,128,192,160,96,32,192,3,1,1,5,1,5,
2055  160,5,7,7,5,0,255,112,136,168,200,168,136,112,3,3,
2056  3,5,0,3,96,160,96,5,3,3,5,0,1,72,144,72,
2057  4,2,2,5,0,1,240,16,3,1,1,5,1,2,224,5,
2058  7,7,5,0,255,112,136,232,200,200,136,112,4,1,1,5,
2059  0,5,240,3,3,3,5,1,3,64,160,64,5,6,6,5,
2060  0,0,32,32,248,32,32,248,2,4,4,5,1,2,192,64,
2061  128,192,2,4,4,5,1,2,192,192,64,192,2,2,2,5,
2062  1,4,64,128,4,5,5,5,0,255,144,144,144,224,128,4,
2063  6,6,5,0,0,112,208,208,80,80,80,2,2,2,5,1,
2064  2,192,192,2,2,2,5,1,255,64,128,3,4,4,5,1,
2065  2,64,192,64,224,3,3,3,5,0,3,64,160,64,5,3,
2066  3,5,0,1,144,72,144,4,7,7,5,0,255,128,128,128,
2067  144,48,112,16,4,7,7,5,0,255,128,128,128,176,16,32,
2068  48,4,7,7,5,0,255,192,192,64,208,48,112,16,3,6,
2069  6,5,1,0,64,0,64,128,160,64,4,6,6,5,0,0,
2070  96,144,144,240,144,144,4,6,6,5,0,0,96,144,144,240,
2071  144,144,4,6,6,5,0,0,96,144,144,240,144,144,4,6,
2072  6,5,0,0,96,144,144,240,144,144,4,6,6,5,0,0,
2073  144,96,144,240,144,144,4,6,6,5,0,0,96,96,144,240,
2074  144,144,4,6,6,5,0,0,112,160,176,224,160,176,4,7,
2075  7,5,0,255,96,144,128,128,144,96,64,4,6,6,5,0,
2076  0,240,128,224,128,128,240,4,6,6,5,0,0,240,128,224,
2077  128,128,240,4,6,6,5,0,0,240,128,224,128,128,240,4,
2078  6,6,5,0,0,240,128,224,128,128,240,3,6,6,5,1,
2079  0,224,64,64,64,64,224,3,6,6,5,1,0,224,64,64,
2080  64,64,224,3,6,6,5,1,0,224,64,64,64,64,224,3,
2081  6,6,5,1,0,224,64,64,64,64,224,4,6,6,5,0,
2082  0,224,80,208,80,80,224,4,6,6,5,0,0,176,144,208,
2083  176,176,144,4,6,6,5,0,0,96,144,144,144,144,96,4,
2084  6,6,5,0,0,96,144,144,144,144,96,4,6,6,5,0,
2085  0,96,144,144,144,144,96,4,6,6,5,0,0,96,144,144,
2086  144,144,96,4,6,6,5,0,0,144,96,144,144,144,96,4,
2087  4,4,5,0,0,144,96,96,144,4,6,6,5,0,0,112,
2088  176,176,208,208,224,4,6,6,5,0,0,144,144,144,144,144,
2089  96,4,6,6,5,0,0,144,144,144,144,144,96,4,6,6,
2090  5,0,0,144,144,144,144,144,96,4,6,6,5,0,0,144,
2091  0,144,144,144,96,3,6,6,5,1,0,160,160,160,64,64,
2092  64,4,6,6,5,0,0,128,224,144,224,128,128,4,6,6,
2093  5,0,0,96,144,160,144,144,160,4,6,6,5,0,0,64,
2094  32,112,144,176,80,4,6,6,5,0,0,32,64,112,144,176,
2095  80,4,6,6,5,0,0,32,80,112,144,176,80,4,6,6,
2096  5,0,0,80,160,112,144,176,80,4,6,6,5,0,0,80,
2097  0,112,144,176,80,4,6,6,5,0,0,96,96,112,144,176,
2098  80,4,4,4,5,0,0,112,176,160,112,3,5,5,5,1,
2099  255,96,128,128,96,64,4,6,6,5,0,0,64,32,96,176,
2100  192,96,4,6,6,5,0,0,32,64,96,176,192,96,4,6,
2101  6,5,0,0,64,160,96,176,192,96,4,6,6,5,0,0,
2102  160,0,96,176,192,96,3,6,6,5,1,0,128,64,192,64,
2103  64,224,3,6,6,5,1,0,64,128,192,64,64,224,3,6,
2104  6,5,1,0,64,160,192,64,64,224,3,6,6,5,1,0,
2105  160,0,192,64,64,224,4,6,6,5,0,0,64,48,96,144,
2106  144,96,4,6,6,5,0,0,80,160,224,144,144,144,4,6,
2107  6,5,0,0,64,32,96,144,144,96,4,6,6,5,0,0,
2108  32,64,96,144,144,96,4,6,6,5,0,0,96,0,96,144,
2109  144,96,4,6,6,5,0,0,80,160,96,144,144,96,4,6,
2110  6,5,0,0,80,0,96,144,144,96,4,5,5,5,0,0,
2111  96,0,240,0,96,4,4,4,5,0,0,112,176,208,224,4,
2112  6,6,5,0,0,64,32,144,144,144,112,4,6,6,5,0,
2113  0,32,64,144,144,144,112,4,6,6,5,0,0,96,0,144,
2114  144,144,112,4,6,6,5,0,0,80,0,144,144,144,112,4,
2115  7,7,5,0,255,32,64,144,144,80,32,64,4,6,6,5,
2116  0,255,128,224,144,144,224,128,4,7,7,5,0,255,80,0,
2117  144,144,80,32,64};
2118 
2119 /*
2120  Fontname: -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1
2121  Copyright: Public domain terminal emulator font. Share and enjoy.
2122  Capital A Height: 7, '1' Height: 7
2123  Calculated Max Values w= 7 h= 9 x= 5 y= 7 dx= 9 dy= 0 ascent= 8 len= 9
2124  Font Bounding box w= 7 h=10 x= 0 y=-2
2125  Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
2126  Pure Font ascent = 7 descent=-2
2127  X Font ascent = 7 descent=-2
2128  Max Font ascent = 8 descent=-2
2129 */
2130 const u8g_fntpgm_uint8_t repetier_6x10[2625] U8G_FONT_SECTION("repetier_6x10") = {
2131  0,7,10,0,254,7,2,105,3,251,0,255,254,8,254,7,
2132  254,5,7,7,6,0,0,168,0,136,0,136,0,168,5,8,
2133  8,6,0,0,8,8,8,40,72,248,64,32,3,3,3,6,
2134  1,4,64,160,64,5,5,5,6,0,0,248,248,248,248,248,
2135  5,5,5,6,0,0,248,136,136,136,248,5,8,8,6,0,
2136  0,32,80,80,80,112,248,248,112,7,5,5,9,0,0,28,
2137  254,130,130,254,5,8,8,6,0,0,136,80,32,136,32,80,
2138  136,136,6,8,8,6,0,0,72,144,72,252,252,120,48,48,
2139  6,8,8,6,0,0,36,72,36,252,252,120,48,48,6,5,
2140  5,6,0,0,252,252,120,48,48,6,2,2,6,0,0,252,
2141  252,6,6,6,6,0,0,72,144,72,144,252,252,6,6,6,
2142  6,0,0,36,72,36,72,252,252,7,7,7,7,0,0,130,
2143  68,56,40,56,68,130,7,7,7,7,0,0,16,16,56,238,
2144  56,16,16,255,255,255,255,255,255,255,255,255,255,255,255,255,
2145  255,255,255,0,0,0,6,5,255,1,7,7,6,2,0,128,
2146  128,128,128,128,0,128,3,3,3,6,1,4,160,160,160,5,
2147  7,7,6,0,0,80,80,248,80,248,80,80,5,7,7,6,
2148  0,0,32,112,160,112,40,112,32,6,8,8,6,0,0,68,
2149  164,72,16,32,72,148,136,5,7,7,6,0,0,64,160,160,
2150  64,168,144,104,1,3,3,6,2,4,128,128,128,3,7,7,
2151  6,1,0,32,64,128,128,128,64,32,3,7,7,6,1,0,
2152  128,64,32,32,32,64,128,5,5,5,6,0,1,136,80,248,
2153  80,136,5,5,5,6,0,1,32,32,248,32,32,3,3,3,
2154  6,1,255,96,64,128,4,1,1,6,1,3,240,2,2,2,
2155  6,1,255,192,192,5,7,7,6,0,0,8,8,16,32,64,
2156  128,128,5,7,7,6,0,0,32,80,136,136,136,80,32,5,
2157  7,7,6,0,0,32,96,160,32,32,32,248,5,7,7,6,
2158  0,0,112,136,8,48,64,128,248,5,7,7,6,0,0,248,
2159  8,16,48,8,136,112,5,7,7,6,0,0,16,48,80,144,
2160  248,16,16,5,7,7,6,0,0,248,128,176,200,8,136,112,
2161  5,7,7,6,0,0,48,64,128,176,200,136,112,5,7,7,
2162  6,0,0,248,8,16,16,32,64,64,5,7,7,6,0,0,
2163  112,136,136,112,136,136,112,5,7,7,6,0,0,112,136,152,
2164  104,8,16,96,2,5,5,6,2,1,192,192,0,192,192,3,
2165  7,7,6,1,255,64,224,64,0,96,64,128,4,7,7,6,
2166  1,0,16,32,64,128,64,32,16,5,3,3,6,0,2,248,
2167  0,248,4,7,7,6,1,0,128,64,32,16,32,64,128,5,
2168  7,7,6,0,0,112,136,16,32,32,0,32,5,7,7,6,
2169  0,0,112,136,152,168,176,128,112,5,7,7,6,0,0,32,
2170  80,136,136,248,136,136,5,7,7,6,0,0,240,72,72,112,
2171  72,72,240,5,7,7,6,0,0,112,136,128,128,128,136,112,
2172  5,7,7,6,0,0,240,72,72,72,72,72,240,5,7,7,
2173  6,0,0,248,128,128,240,128,128,248,5,7,7,6,0,0,
2174  248,128,128,240,128,128,128,5,7,7,6,0,0,112,136,128,
2175  128,152,136,112,5,7,7,6,0,0,136,136,136,248,136,136,
2176  136,3,7,7,6,1,0,224,64,64,64,64,64,224,5,7,
2177  7,6,0,0,56,16,16,16,16,144,96,5,7,7,6,0,
2178  0,136,144,160,192,160,144,136,5,7,7,6,0,0,128,128,
2179  128,128,128,128,248,5,7,7,6,0,0,136,136,216,168,136,
2180  136,136,5,7,7,6,0,0,136,136,200,168,152,136,136,5,
2181  7,7,6,0,0,112,136,136,136,136,136,112,5,7,7,6,
2182  0,0,240,136,136,240,128,128,128,5,8,8,6,0,255,112,
2183  136,136,136,136,168,112,8,5,7,7,6,0,0,240,136,136,
2184  240,160,144,136,5,7,7,6,0,0,112,136,128,112,8,136,
2185  112,5,7,7,6,0,0,248,32,32,32,32,32,32,5,7,
2186  7,6,0,0,136,136,136,136,136,136,112,5,7,7,6,0,
2187  0,136,136,136,80,80,80,32,5,7,7,6,0,0,136,136,
2188  136,168,168,216,136,5,7,7,6,0,0,136,136,80,32,80,
2189  136,136,5,7,7,6,0,0,136,136,80,32,32,32,32,5,
2190  7,7,6,0,0,248,8,16,32,64,128,248,3,7,7,6,
2191  1,0,224,128,128,128,128,128,224,5,7,7,6,0,0,128,
2192  128,64,32,16,8,8,3,7,7,6,1,0,224,32,32,32,
2193  32,32,224,5,3,3,6,0,4,32,80,136,5,1,1,6,
2194  0,255,248,2,2,2,6,2,6,128,64,5,5,5,6,0,
2195  0,112,8,120,136,120,5,7,7,6,0,0,128,128,176,200,
2196  136,200,176,5,5,5,6,0,0,112,136,128,136,112,5,7,
2197  7,6,0,0,8,8,104,152,136,152,104,5,5,5,6,0,
2198  0,112,136,248,128,112,5,7,7,6,0,0,48,72,64,240,
2199  64,64,64,5,7,7,6,0,254,120,136,136,120,8,136,112,
2200  5,7,7,6,0,0,128,128,176,200,136,136,136,3,7,7,
2201  6,1,0,64,0,192,64,64,64,224,4,9,9,6,1,254,
2202  16,0,48,16,16,16,144,144,96,5,7,7,6,0,0,128,
2203  128,136,144,224,144,136,3,7,7,6,1,0,192,64,64,64,
2204  64,64,224,5,5,5,6,0,0,208,168,168,168,136,5,5,
2205  5,6,0,0,176,200,136,136,136,5,5,5,6,0,0,112,
2206  136,136,136,112,5,7,7,6,0,254,176,200,136,200,176,128,
2207  128,5,7,7,6,0,254,104,152,136,152,104,8,8,5,5,
2208  5,6,0,0,176,200,128,128,128,5,5,5,6,0,0,112,
2209  128,112,8,240,5,7,7,6,0,0,64,64,240,64,64,72,
2210  48,5,5,5,6,0,0,136,136,136,152,104,5,5,5,6,
2211  0,0,136,136,80,80,32,5,5,5,6,0,0,136,136,168,
2212  168,80,5,5,5,6,0,0,136,80,32,80,136,5,7,7,
2213  6,0,254,136,136,152,104,8,136,112,5,5,5,6,0,0,
2214  248,16,32,64,248,4,7,7,6,1,0,48,64,32,192,32,
2215  64,48,1,7,7,6,2,0,128,128,128,128,128,128,128,4,
2216  7,7,6,1,0,192,32,64,48,64,32,192,5,3,3,6,
2217  0,4,72,168,144,255,255,255,255,255,255,255,255,255,255,255,
2218  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
2219  255,255,255,255,255,255,255,1,7,7,6,2,0,128,0,128,
2220  128,128,128,128,5,7,7,6,0,255,32,120,160,160,160,120,
2221  32,5,7,7,6,0,0,48,72,64,224,64,72,176,5,5,
2222  5,6,0,0,136,112,80,112,136,5,8,8,6,0,255,136,
2223  136,80,32,248,32,32,32,1,7,7,6,2,0,128,128,128,
2224  0,128,128,128,5,8,8,6,0,255,112,128,224,144,72,56,
2225  8,112,3,1,1,6,1,7,160,5,7,7,6,0,0,112,
2226  136,168,200,168,136,112,4,6,6,6,1,1,112,144,176,80,
2227  0,240,6,5,5,6,0,0,36,72,144,72,36,4,2,2,
2228  6,1,2,240,16,255,5,7,7,6,0,0,112,136,232,200,
2229  200,136,112,5,1,1,6,0,7,248,3,3,3,6,1,4,
2230  64,160,64,5,6,6,6,0,0,32,32,248,32,32,248,4,
2231  5,5,6,1,3,96,144,32,64,240,4,5,5,6,1,3,
2232  224,16,96,16,224,2,2,2,6,2,6,64,128,255,5,7,
2233  7,6,0,0,120,232,232,104,40,40,40,1,1,1,6,2,
2234  3,128,2,2,2,6,2,254,64,128,3,5,5,6,1,3,
2235  64,192,64,64,224,4,6,6,6,1,1,96,144,144,96,0,
2236  240,6,5,5,6,0,0,144,72,36,72,144,6,9,9,6,
2237  0,255,64,192,64,64,228,12,20,60,4,6,9,9,6,0,
2238  255,64,192,64,64,232,20,4,8,28,5,9,9,6,0,255,
2239  192,32,64,32,200,24,40,120,8,5,7,7,6,0,0,32,
2240  0,32,32,64,136,112,5,8,8,6,0,0,64,32,112,136,
2241  136,248,136,136,5,8,8,6,0,0,16,32,112,136,136,248,
2242  136,136,5,8,8,6,0,0,32,80,112,136,136,248,136,136,
2243  5,8,8,6,0,0,72,176,112,136,136,248,136,136,5,8,
2244  8,6,0,0,80,0,112,136,136,248,136,136,5,8,8,6,
2245  0,0,32,80,112,136,136,248,136,136,6,7,7,6,0,0,
2246  60,80,144,156,240,144,156,5,9,9,6,0,254,112,136,128,
2247  128,128,136,112,32,64,5,8,8,6,0,0,64,248,128,128,
2248  240,128,128,248,5,8,8,6,0,0,16,248,128,128,240,128,
2249  128,248,5,8,8,6,0,0,32,248,128,128,240,128,128,248,
2250  5,8,8,6,0,0,80,248,128,128,240,128,128,248,3,8,
2251  8,6,1,0,128,64,224,64,64,64,64,224,3,8,8,6,
2252  1,0,32,64,224,64,64,64,64,224,3,8,8,6,1,0,
2253  64,160,224,64,64,64,64,224,3,8,8,6,1,0,160,0,
2254  224,64,64,64,64,224,5,7,7,6,0,0,240,72,72,232,
2255  72,72,240,5,8,8,6,0,0,40,80,136,200,168,152,136,
2256  136,5,8,8,6,0,0,64,32,112,136,136,136,136,112,5,
2257  8,8,6,0,0,16,32,112,136,136,136,136,112,5,8,8,
2258  6,0,0,32,80,112,136,136,136,136,112,5,8,8,6,0,
2259  0,40,80,112,136,136,136,136,112,5,8,8,6,0,0,80,
2260  0,112,136,136,136,136,112,5,5,5,6,0,0,136,80,32,
2261  80,136,5,7,7,6,0,0,112,152,152,168,200,200,112,5,
2262  8,8,6,0,0,64,32,136,136,136,136,136,112,5,8,8,
2263  6,0,0,16,32,136,136,136,136,136,112,5,8,8,6,0,
2264  0,32,80,0,136,136,136,136,112,5,8,8,6,0,0,80,
2265  0,136,136,136,136,136,112,5,8,8,6,0,0,16,32,136,
2266  136,80,32,32,32,5,7,7,6,0,0,128,240,136,240,128,
2267  128,128,5,7,7,6,0,0,112,136,144,160,144,136,176,5,
2268  8,8,6,0,0,64,32,0,112,8,120,136,120,5,8,8,
2269  6,0,0,16,32,0,112,8,120,136,120,5,8,8,6,0,
2270  0,32,80,0,112,8,120,136,120,5,8,8,6,0,0,40,
2271  80,0,112,8,120,136,120,5,7,7,6,0,0,80,0,112,
2272  8,120,136,120,5,8,8,6,0,0,32,80,32,112,8,120,
2273  136,120,6,5,5,6,0,0,120,20,124,144,124,5,7,7,
2274  6,0,254,112,136,128,136,112,32,64,5,8,8,6,0,0,
2275  64,32,0,112,136,248,128,112,5,8,8,6,0,0,16,32,
2276  0,112,136,248,128,112,5,8,8,6,0,0,32,80,0,112,
2277  136,248,128,112,5,7,7,6,0,0,80,0,112,136,248,128,
2278  112,3,8,8,6,1,0,128,64,0,192,64,64,64,224,3,
2279  8,8,6,1,0,64,128,0,192,64,64,64,224,3,8,8,
2280  6,1,0,64,160,0,192,64,64,64,224,3,7,7,6,1,
2281  0,160,0,192,64,64,64,224,5,7,7,6,0,0,192,48,
2282  112,136,136,136,112,5,8,8,6,0,0,40,80,0,176,200,
2283  136,136,136,5,8,8,6,0,0,64,32,0,112,136,136,136,
2284  112,5,8,8,6,0,0,16,32,0,112,136,136,136,112,5,
2285  8,8,6,0,0,32,80,0,112,136,136,136,112,5,8,8,
2286  6,0,0,40,80,0,112,136,136,136,112,5,7,7,6,0,
2287  0,80,0,112,136,136,136,112,5,5,5,6,0,1,32,0,
2288  248,0,32,5,5,5,6,0,0,120,152,168,200,240,5,8,
2289  8,6,0,0,64,32,0,136,136,136,152,104,5,8,8,6,
2290  0,0,16,32,0,136,136,136,152,104,5,8,8,6,0,0,
2291  32,80,0,136,136,136,152,104,5,7,7,6,0,0,80,0,
2292  136,136,136,152,104,5,9,9,6,0,254,16,32,136,136,152,
2293  104,8,136,112,5,8,8,6,0,254,128,240,136,136,136,240,
2294  128,128,5,9,9,6,0,254,80,0,136,136,152,104,8,136,
2295  112};
2296 /*
2297  Fontname: -Misc-Fixed-Medium-R-SemiCondensed--12-110-75-75-C-60-ISO10646-1
2298  Copyright: Public domain terminal emulator font. Share and enjoy.
2299  Capital A Height: 3, '1' Height: 8
2300  Calculated Max Values w= 6 h=12 x= 5 y= 8 dx= 6 dy= 0 ascent=10 len=12
2301  Font Bounding box w= 6 h=12 x= 0 y=-2
2302  Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
2303  Pure Font ascent = 3 descent= 0
2304  X Font ascent = 8 descent= 0
2305  Max Font ascent =10 descent=-2
2306 */
2307 const u8g_fntpgm_uint8_t u8g_font_6x12_67_75[2382] U8G_FONT_SECTION("u8g_font_6x12_67_75") = {
2308  1,6,12,0,254,3,2,41,3,99,0,255,0,10,254,8,
2309  0,2,87,103,168,0,136,0,136,0,168,2,87,103,240,136,
2310  232,168,232,136,240,2,87,103,112,168,248,168,248,168,112,2,
2311  87,103,112,136,8,8,8,136,112,18,69,101,96,144,16,144,
2312  96,1,88,104,112,136,128,128,136,120,8,8,2,87,103,32,
2313  32,32,32,168,112,32,2,103,103,248,252,252,156,252,252,248,
2314  2,87,103,112,248,248,168,248,248,112,255,255,255,255,255,255,
2315  255,3,85,101,32,64,248,64,32,2,87,103,32,112,168,32,
2316  32,32,32,3,85,101,32,16,248,16,32,2,87,103,32,32,
2317  32,32,168,112,32,4,83,99,80,248,80,2,87,103,32,112,
2318  168,32,168,112,32,2,89,105,192,240,224,160,32,16,16,8,
2319  8,2,89,105,24,120,56,40,32,64,64,128,128,2,89,105,
2320  128,128,64,64,32,40,56,120,24,2,89,105,8,8,16,16,
2321  32,160,224,240,192,3,101,101,40,72,252,80,48,3,101,101,
2322  48,40,252,72,80,4,99,99,192,216,100,4,99,99,12,108,
2323  152,3,101,101,40,80,252,80,40,2,88,104,32,112,168,112,
2324  168,32,32,32,3,101,101,80,40,252,40,80,2,88,104,32,
2325  32,32,168,112,168,112,32,3,101,101,36,72,240,72,36,3,
2326  101,101,144,72,60,72,144,3,85,101,40,72,248,72,40,2,
2327  87,103,32,112,168,32,32,32,248,3,85,101,160,144,248,144,
2328  160,2,87,103,248,32,32,32,168,112,32,2,87,103,32,112,
2329  168,32,168,112,248,3,101,101,40,68,248,64,32,3,101,101,
2330  80,136,124,8,16,3,101,101,32,76,252,72,40,3,101,101,
2331  16,200,252,72,80,3,100,100,72,220,236,72,3,101,101,8,
2332  88,252,104,64,2,87,103,128,144,176,208,144,56,16,2,88,
2333  104,32,64,248,72,40,8,8,8,2,88,104,32,16,248,144,
2334  160,128,128,128,2,88,104,8,8,8,40,72,248,64,32,2,
2335  87,103,128,128,160,144,248,16,32,3,84,100,240,16,56,16,
2336  3,85,101,8,8,72,248,64,3,85,101,48,72,72,232,72,
2337  3,85,101,96,144,144,184,16,2,88,104,248,128,224,192,160,
2338  32,16,16,2,89,105,160,192,248,192,168,24,248,24,40,2,
2339  86,102,56,48,168,136,136,112,2,86,102,224,96,168,136,136,
2340  112,5,83,99,32,64,248,3,83,99,248,64,32,34,56,104,
2341  128,192,160,128,128,128,128,128,2,56,104,32,96,160,32,32,
2342  32,32,32,5,83,99,32,16,248,3,83,99,248,16,32,34,
2343  56,104,128,128,128,128,128,160,192,128,2,56,104,32,32,32,
2344  32,32,160,96,32,2,89,105,32,16,248,16,32,64,248,64,
2345  32,2,88,104,80,240,80,80,80,80,120,80,2,89,105,32,
2346  64,248,64,32,16,248,16,32,2,89,105,32,64,248,64,32,
2347  64,248,64,32,2,88,104,80,248,80,80,80,80,80,80,2,
2348  89,105,32,16,248,16,32,16,248,16,32,2,88,104,80,80,
2349  80,80,80,80,248,80,2,87,103,32,64,248,0,248,16,32,
2350  2,87,103,32,16,248,0,248,64,32,2,103,103,20,40,124,
2351  144,124,32,80,2,103,103,8,88,252,164,252,104,64,2,103,
2352  103,160,80,248,36,248,16,40,3,85,101,32,120,128,120,32,
2353  2,87,103,32,80,216,80,80,80,80,3,85,101,32,240,8,
2354  240,32,2,87,103,80,80,80,80,216,80,32,3,101,101,72,
2355  252,132,252,72,2,88,104,32,80,216,80,80,216,80,32,2,
2356  102,102,248,160,208,168,148,8,2,102,102,124,20,44,84,164,
2357  64,2,102,102,64,164,84,44,20,124,2,102,102,8,148,168,
2358  208,160,248,2,103,103,16,60,64,252,64,60,16,2,103,103,
2359  32,240,8,252,8,240,32,3,100,100,64,232,212,64,3,100,
2360  100,8,92,172,8,2,88,104,32,112,168,32,112,32,112,32,
2361  2,88,104,32,112,32,112,32,168,112,32,3,101,101,32,64,
2362  212,64,32,2,88,104,32,112,136,32,0,32,0,32,3,101,
2363  101,16,8,172,8,16,2,88,104,32,0,32,0,32,136,112,
2364  32,3,85,101,160,192,248,192,160,3,85,101,40,24,248,24,
2365  40,3,85,101,32,120,136,120,32,2,88,104,32,80,216,80,
2366  80,80,80,112,3,85,101,32,240,136,240,32,2,88,104,112,
2367  80,80,80,80,216,80,32,2,89,105,32,80,216,80,112,0,
2368  112,80,112,2,89,105,32,80,216,80,80,80,216,136,248,2,
2369  89,105,32,80,248,136,80,80,216,136,248,2,89,105,32,112,
2370  248,112,112,112,248,168,248,2,89,105,32,80,216,80,216,80,
2371  80,80,112,2,89,105,32,80,216,80,216,80,216,136,248,3,
2372  85,101,160,240,136,240,160,2,88,104,248,128,176,160,144,16,
2373  8,8,2,88,104,128,128,64,72,40,104,8,248,2,88,104,
2374  32,80,216,80,80,216,80,32,3,101,101,16,104,252,104,16,
2375  2,88,104,80,120,80,80,80,80,240,80,2,89,105,16,248,
2376  16,16,248,16,16,248,16,3,101,101,40,72,252,72,40,3,
2377  101,101,80,72,252,72,80,3,101,101,48,120,252,120,48,3,
2378  101,101,56,88,252,88,56,3,101,101,112,104,252,104,112,3,
2379  101,101,48,120,252,120,48,3,85,101,32,96,184,96,32,3,
2380  85,101,32,48,232,48,32,3,101,101,48,120,180,120,48,6,
2381  102,102,252,252,252,252,252,252,0,98,98,252,252,0,99,99,
2382  252,252,252,0,101,101,252,252,252,252,252,0,102,102,252,252,
2383  252,252,252,252,0,104,104,252,252,252,252,252,252,252,252,0,
2384  105,105,252,252,252,252,252,252,252,252,252,0,107,107,252,252,
2385  252,252,252,252,252,252,252,252,252,0,108,108,252,252,252,252,
2386  252,252,252,252,252,252,252,252,0,92,108,248,248,248,248,248,
2387  248,248,248,248,248,248,248,0,76,108,240,240,240,240,240,240,
2388  240,240,240,240,240,240,0,76,108,240,240,240,240,240,240,240,
2389  240,240,240,240,240,0,60,108,224,224,224,224,224,224,224,224,
2390  224,224,224,224,0,44,108,192,192,192,192,192,192,192,192,192,
2391  192,192,192,0,44,108,192,192,192,192,192,192,192,192,192,192,
2392  192,192,0,28,108,128,128,128,128,128,128,128,128,128,128,128,
2393  128,48,60,108,224,224,224,224,224,224,224,224,224,224,224,224,
2394  1,107,107,168,0,84,0,168,0,84,0,168,0,84,0,108,
2395  108,168,84,168,84,168,84,168,84,168,84,168,84,0,108,108,
2396  84,252,168,252,84,252,168,252,84,252,168,252,10,98,98,252,
2397  252,80,28,108,128,128,128,128,128,128,128,128,128,128,128,128,
2398  0,54,102,224,224,224,224,224,224,48,54,102,224,224,224,224,
2399  224,224,6,54,102,224,224,224,224,224,224,0,108,108,224,224,
2400  224,224,224,224,252,252,252,252,252,252,0,108,108,224,224,224,
2401  224,224,224,28,28,28,28,28,28,0,108,108,252,252,252,252,
2402  252,252,224,224,224,224,224,224,0,108,108,252,252,252,252,252,
2403  252,28,28,28,28,28,28,54,54,102,224,224,224,224,224,224,
2404  0,108,108,28,28,28,28,28,28,224,224,224,224,224,224,0,
2405  108,108,28,28,28,28,28,28,252,252,252,252,252,252,2,85,
2406  101,248,248,248,248,248,2,85,101,248,136,136,136,248,2,85,
2407  101,112,136,136,136,112,2,85,101,248,136,168,136,248,2,85,
2408  101,248,136,248,136,248,2,85,101,248,168,168,168,248,2,85,
2409  101,248,168,248,168,248,2,85,101,248,200,168,152,248,2,85,
2410  101,248,152,168,200,248,2,85,101,248,216,168,216,248,20,51,
2411  99,224,224,224,20,51,99,224,160,224,3,101,101,252,252,252,
2412  252,252,3,101,101,252,132,132,132,252,17,74,106,240,240,240,
2413  240,240,240,240,240,240,240,17,74,106,240,144,144,144,144,144,
2414  144,144,144,240,4,99,99,60,120,240,4,99,99,60,72,240,
2415  2,87,103,32,32,112,112,248,248,248,2,87,103,32,32,80,
2416  80,136,136,248,3,85,101,32,32,112,112,248,3,85,101,32,
2417  32,80,80,248,18,71,103,128,192,224,240,224,192,128,18,71,
2418  103,128,192,160,144,160,192,128,19,53,101,128,192,224,192,128,
2419  19,53,101,128,192,160,192,128,3,101,101,192,240,252,240,192,
2420  3,101,101,192,176,140,176,192,2,87,103,248,248,248,112,112,
2421  32,32,2,87,103,248,136,136,80,80,32,32,2,85,101,248,
2422  112,112,32,32,2,85,101,248,80,80,32,32,18,71,103,16,
2423  48,112,240,112,48,16,18,71,103,16,48,80,144,80,48,16,
2424  19,53,101,32,96,224,96,32,19,53,101,32,96,160,96,32,
2425  3,101,101,12,60,252,60,12,3,101,101,12,52,196,52,12,
2426  3,85,101,32,112,248,112,32,3,85,101,32,80,136,80,32,
2427  3,85,101,32,80,168,80,32,2,102,102,48,72,180,180,72,
2428  48,2,87,103,32,80,80,136,80,80,32,2,102,102,48,72,
2429  132,132,72,48,2,102,102,32,8,128,4,64,16,2,85,101,
2430  112,168,168,168,112,2,87,103,112,136,168,216,168,136,112,2,
2431  102,102,48,120,252,252,120,48,2,102,102,48,104,228,228,104,
2432  48,2,102,102,48,88,156,156,88,48,2,102,102,48,72,132,
2433  252,120,48,2,102,102,48,120,252,132,72,48,2,102,102,48,
2434  88,156,132,72,48,2,102,102,48,104,228,132,72,48,18,89,
2435  105,8,56,120,120,248,120,120,56,8,2,89,105,128,224,240,
2436  240,248,240,240,224,128,0,108,108,252,252,252,252,204,132,132,
2437  204,252,252,252,252,0,108,108,252,252,252,204,180,120,120,180,
2438  204,252,252,252,6,102,102,252,252,252,204,180,120,0,102,102,
2439  120,180,204,252,252,252,5,51,99,32,64,128,53,51,99,128,
2440  64,32,50,51,99,32,64,128,2,51,99,128,64,32,5,99,
2441  99,48,72,132,2,99,99,132,72,48,2,85,101,8,24,56,
2442  120,248,2,85,101,128,192,224,240,248,2,85,101,248,240,224,
2443  192,128,2,85,101,248,120,56,24,8,2,85,101,112,136,136,
2444  136,112,2,85,101,248,232,232,232,248,2,85,101,248,184,184,
2445  184,248,2,85,101,248,248,232,200,248,2,85,101,248,152,184,
2446  248,248,2,85,101,248,168,168,168,248,2,87,103,32,32,80,
2447  112,168,136,248,2,87,103,32,32,112,112,232,232,248,2,87,
2448  103,32,32,112,112,184,184,248,2,103,103,48,72,132,132,132,
2449  72,48,2,85,101,248,168,232,136,248,2,85,101,248,136,232,
2450  168,248,2,85,101,248,136,184,168,248,2,85,101,248,168,184,
2451  136,248,2,85,101,112,168,232,136,112,2,85,101,112,136,232,
2452  168,112,2,85,101,112,136,184,168,112,2,85,101,112,168,184,
2453  136,112,3,85,101,248,144,160,192,128,3,85,101,248,72,40,
2454  24,8,3,85,101,128,192,160,144,248,20,68,100,240,144,144,
2455  240,19,68,100,240,240,240,240,20,68,100,240,144,144,240,20,
2456  68,100,240,240,240,240,3,85,101,8,24,40,72,248};
2457 // ======== u8g_dev_st7920_128x64.c ==============
2458 
2459 /*
2460 
2461  u8g_dev_st7920_128x64.c
2462 
2463  Universal 8bit Graphics Library
2464 
2465  Copyright (c) 2011, olikraus@gmail.com
2466  All rights reserved.
2467 
2468  Redistribution and use in source and binary forms, with or without modification,
2469  are permitted provided that the following conditions are met:
2470 
2471  * Redistributions of source code must retain the above copyright notice, this list
2472  of conditions and the following disclaimer.
2473 
2474  * Redistributions in binary form must reproduce the above copyright notice, this
2475  list of conditions and the following disclaimer in the documentation and/or other
2476  materials provided with the distribution.
2477 
2478  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
2479  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
2480  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2481  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2482  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
2483  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2484  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2485  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2486  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2487  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2488  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2489  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2490  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2491 
2492 
2493 */
2494 
2495 
2496 #define WIDTH 128
2497 #define HEIGHT 64
2498 #define PAGE_HEIGHT 8
2499 
2500 
2501 /* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
2502 static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = {
2503  U8G_ESC_CS(0), /* disable chip */
2504  U8G_ESC_ADR(0), /* instruction mode */
2505  U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
2506  U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
2507  U8G_ESC_CS(1), /* enable chip */
2508  U8G_ESC_DLY(50), /* delay 50 ms */
2509 
2510  0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
2511  0x00c, /* display on, cursor & blink off; 0x08: all off */
2512  0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
2513  0x002, /* disable scroll, enable CGRAM adress */
2514  0x001, /* clear RAM, needs 1.6 ms */
2515  U8G_ESC_DLY(100), /* delay 100 ms */
2516 
2517  U8G_ESC_CS(0), /* disable chip */
2518  U8G_ESC_END /* end of sequence */
2519 };
2520 
2521 uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2522 {
2523  switch(msg)
2524  {
2525  case U8G_DEV_MSG_INIT:
2527  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
2528  break;
2529  case U8G_DEV_MSG_STOP:
2530  break;
2531  case U8G_DEV_MSG_PAGE_NEXT:
2532  {
2533  uint8_t y, i;
2534  uint8_t *ptr;
2535  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2536 
2537  u8g_SetAddress(u8g, dev, 0); /* cmd mode */
2538  u8g_SetChipSelect(u8g, dev, 1);
2539  y = pb->p.page_y0;
2540  ptr = (uint8_t*)pb->buf;
2541  for( i = 0; i < 8; i ++ )
2542  {
2543  u8g_SetAddress(u8g, dev, 0); /* cmd mode */
2544  u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
2545 
2546  if ( y < 32 )
2547  {
2548  u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
2549  u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
2550  }
2551  else
2552  {
2553  u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
2554  u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
2555  }
2556 
2557  u8g_SetAddress(u8g, dev, 1); /* data mode */
2558  u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
2559  ptr += WIDTH/8;
2560  y++;
2561  }
2562  u8g_SetChipSelect(u8g, dev, 0);
2563  }
2564  break;
2565  }
2566  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
2567 }
2568 
2569 uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2570 {
2571  switch(msg)
2572  {
2573  case U8G_DEV_MSG_INIT:
2575  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
2576  break;
2577  case U8G_DEV_MSG_STOP:
2578  break;
2579  case U8G_DEV_MSG_PAGE_NEXT:
2580  {
2581  uint8_t y, i;
2582  uint8_t *ptr;
2583  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2584 
2585  u8g_SetAddress(u8g, dev, 0); /* cmd mode */
2586  u8g_SetChipSelect(u8g, dev, 1);
2587  y = pb->p.page_y0;
2588  ptr = (uint8_t*)pb->buf;
2589  for( i = 0; i < 32; i ++ )
2590  {
2591  u8g_SetAddress(u8g, dev, 0); /* cmd mode */
2592  u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
2593 
2594  if ( y < 32 )
2595  {
2596  u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
2597  u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
2598  }
2599  else
2600  {
2601  u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
2602  u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
2603  }
2604 
2605  u8g_SetAddress(u8g, dev, 1); /* data mode */
2606  u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
2607  ptr += WIDTH/8;
2608  y++;
2609  }
2610  u8g_SetChipSelect(u8g, dev, 0);
2611  }
2612  break;
2613  }
2614  return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
2615 }
2616 
2621 
2622 
2623 
2624 #define QWIDTH (WIDTH*4)
2625 uint8_t u8g_dev_st7920_128x64_4x_buf[QWIDTH] U8G_NOCOMMON ;
2626 u8g_pb_t u8g_dev_st7920_128x64_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_128x64_4x_buf};
2631 
2632 // ================ u8g_dev_ssd1306_128x64.c ==========
2633 
2634 /*
2635 
2636  u8g_dev_ssd1306_128x64.c
2637 
2638  Universal 8bit Graphics Library
2639 
2640  Copyright (c) 2011, olikraus@gmail.com
2641  All rights reserved.
2642 
2643  Redistribution and use in source and binary forms, with or without modification,
2644  are permitted provided that the following conditions are met:
2645 
2646  * Redistributions of source code must retain the above copyright notice, this list
2647  of conditions and the following disclaimer.
2648 
2649  * Redistributions in binary form must reproduce the above copyright notice, this
2650  list of conditions and the following disclaimer in the documentation and/or other
2651  materials provided with the distribution.
2652 
2653  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
2654  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
2655  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2656  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2657  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
2658  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2659  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2660  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2661  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2662  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2663  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2664  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2665  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2666 
2667 
2668 */
2669 
2670 #define WIDTH 128
2671 #define HEIGHT 64
2672 #define PAGE_HEIGHT 8
2673 
2674 /* init sequence adafruit 128x64 OLED (NOT TESTED) */
2675 static const uint8_t u8g_dev_ssd1306_128x64_adafruit1_init_seq[] PROGMEM = {
2676  U8G_ESC_CS(0), /* disable chip */
2677  U8G_ESC_ADR(0), /* instruction mode */
2678  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
2679  U8G_ESC_CS(1), /* enable chip */
2680 
2681  0x0ae, /* display off, sleep mode */
2682  0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
2683  0x0a8, 0x03f, /* */
2684 
2685  0x0d3, 0x000, /* */
2686 
2687  0x040, /* start line */
2688 
2689  0x08d, 0x010, /* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
2690 
2691  0x020, 0x000, /* */
2692  0x0a1, /* segment remap a0/a1*/
2693  0x0c8, /* c0: scan dir normal, c8: reverse */
2694  0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
2695  0x081, 0x09f, /* [1] set contrast control */
2696  0x0d9, 0x022, /* [1] pre-charge period 0x022/f1*/
2697  0x0db, 0x040, /* vcomh deselect level */
2698 
2699  0x02e, /* 2012-05-27: Deactivate scroll */
2700  0x0a4, /* output ram to display */
2701  0x0a6, /* none inverted normal display mode */
2702  0x0af, /* display on */
2703 
2704  U8G_ESC_CS(0), /* disable chip */
2705  U8G_ESC_END /* end of sequence */
2706 };
2707 
2708 /* init sequence adafruit 128x64 OLED (NOT TESTED) */
2709 static const uint8_t u8g_dev_ssd1306_128x64_adafruit2_init_seq[] PROGMEM = {
2710  U8G_ESC_CS(0), /* disable chip */
2711  U8G_ESC_ADR(0), /* instruction mode */
2712  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
2713  U8G_ESC_CS(1), /* enable chip */
2714 
2715  0x0ae, /* display off, sleep mode */
2716  0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
2717  0x0a8, 0x03f, /* */
2718 
2719  0x0d3, 0x000, /* */
2720 
2721  0x040, /* start line */
2722 
2723  0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
2724 
2725  0x020, 0x000, /* */
2726  0x0a1, /* segment remap a0/a1*/
2727  0x0c8, /* c0: scan dir normal, c8: reverse */
2728  0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
2729  0x081, 0x0cf, /* [2] set contrast control */
2730  0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
2731  0x0db, 0x040, /* vcomh deselect level */
2732 
2733  0x02e, /* 2012-05-27: Deactivate scroll */
2734  0x0a4, /* output ram to display */
2735  0x0a6, /* none inverted normal display mode */
2736  0x0af, /* display on */
2737 
2738  U8G_ESC_CS(0), /* disable chip */
2739  U8G_ESC_END /* end of sequence */
2740 };
2741 
2742 /* init sequence adafruit 128x64 OLED (NOT TESTED), like adafruit3, but with page addressing mode */
2743 static const uint8_t u8g_dev_ssd1306_128x64_adafruit3_init_seq[] PROGMEM = {
2744  U8G_ESC_CS(0), /* disable chip */
2745  U8G_ESC_ADR(0), /* instruction mode */
2746  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
2747  U8G_ESC_CS(1), /* enable chip */
2748 
2749  0x0ae, /* display off, sleep mode */
2750  0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
2751  0x0a8, 0x03f, /* */
2752 
2753  0x0d3, 0x000, /* */
2754 
2755  0x040, /* start line */
2756 
2757  0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
2758 
2759  0x020, 0x002, /* 2012-05-27: page addressing mode */
2760  0x0a1, /* segment remap a0/a1*/
2761  0x0c8, /* c0: scan dir normal, c8: reverse */
2762  0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
2763  0x081, 0x0cf, /* [2] set contrast control */
2764  0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
2765  0x0db, 0x040, /* vcomh deselect level */
2766 
2767  0x02e, /* 2012-05-27: Deactivate scroll */
2768  0x0a4, /* output ram to display */
2769  0x0a6, /* none inverted normal display mode */
2770  0x0af, /* display on */
2771 
2772  U8G_ESC_CS(0), /* disable chip */
2773  U8G_ESC_END /* end of sequence */
2774 };
2775 
2776 /* init sequence Univision datasheet (NOT TESTED) */
2777 static const uint8_t u8g_dev_ssd1306_128x64_univision_init_seq[] PROGMEM = {
2778  U8G_ESC_CS(0), /* disable chip */
2779  U8G_ESC_ADR(0), /* instruction mode */
2780  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
2781  U8G_ESC_CS(1), /* enable chip */
2782 
2783  0x0ae, /* display off, sleep mode */
2784  0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
2785  0x0a8, 0x03f, /* multiplex ratio */
2786  0x0d3, 0x000, /* display offset */
2787  0x040, /* start line */
2788  0x08d, 0x010, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
2789  0x0a1, /* segment remap a0/a1*/
2790  0x0c8, /* c0: scan dir normal, c8: reverse */
2791  0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
2792  0x081, 0x09f, /* set contrast control */
2793  0x0d9, 0x022, /* pre-charge period */
2794  0x0db, 0x040, /* vcomh deselect level */
2795  0x022, 0x000, /* page addressing mode WRONG: 3 byte cmd! */
2796  0x0a4, /* output ram to display */
2797  0x0a6, /* none inverted normal display mode */
2798  0x0af, /* display on */
2799  U8G_ESC_CS(0), /* disable chip */
2800  U8G_ESC_END /* end of sequence */
2801 };
2802 
2803 /* select one init sequence here */
2804 //#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_univision_init_seq
2805 //#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit1_init_seq
2806 // 26. Apr 2014: in this thead: http://forum.arduino.cc/index.php?topic=234930.msg1696754;topicseen#msg1696754
2807 // it is mentiond, that adafruit2_init_seq works better --> this will be used by the ssd1306_adafruit device
2808 //#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit2_init_seq
2809 
2810 #define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit3_init_seq
2811 
2812 
2813 static const uint8_t u8g_dev_ssd1306_128x64_data_start[] PROGMEM = {
2814  U8G_ESC_ADR(0), /* instruction mode */
2815  U8G_ESC_CS(1), /* enable chip */
2816  0x010, /* set upper 4 bit of the col adr to 0 */
2817  0x000, /* set lower 4 bit of the col adr to 0 */
2818  U8G_ESC_END /* end of sequence */
2819 };
2820 
2821 /* the sh1106 is compatible to the ssd1306, but is 132x64. display seems to be centered */
2822 static const uint8_t u8g_dev_sh1106_128x64_data_start[] PROGMEM = {
2823  U8G_ESC_ADR(0), /* instruction mode */
2824  U8G_ESC_CS(1), /* enable chip */
2825  0x010, /* set upper 4 bit of the col adr to 0 */
2826  0x002, /* set lower 4 bit of the col adr to 2 (centered display with sh1106) */
2827  U8G_ESC_END /* end of sequence */
2828 };
2829 
2830 static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
2831  U8G_ESC_ADR(0), /* instruction mode */
2832  U8G_ESC_CS(1), /* enable chip */
2833  0x0ae, /* display off */
2834  U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
2835  U8G_ESC_END /* end of sequence */
2836 };
2837 
2838 static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
2839  U8G_ESC_ADR(0), /* instruction mode */
2840  U8G_ESC_CS(1), /* enable chip */
2841  0x0af, /* display on */
2842  U8G_ESC_DLY(50), /* delay 50 ms */
2843  U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
2844  U8G_ESC_END /* end of sequence */
2845 };
2846 
2847 uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2848 {
2849  switch(msg)
2850  {
2851  case U8G_DEV_MSG_INIT:
2853  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_adafruit2_init_seq);
2854  break;
2855  case U8G_DEV_MSG_STOP:
2856  break;
2857  case U8G_DEV_MSG_PAGE_NEXT:
2858  {
2859  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2860  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
2861  u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
2862  u8g_SetAddress(u8g, dev, 1); /* data mode */
2863  if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
2864  return 0;
2865  u8g_SetChipSelect(u8g, dev, 0);
2866  }
2867  break;
2868  case U8G_DEV_MSG_SLEEP_ON:
2869  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
2870  return 1;
2871  case U8G_DEV_MSG_SLEEP_OFF:
2872  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
2873  return 1;
2874  }
2875  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
2876 }
2877 
2878 uint8_t u8g_dev_ssd1306_adafruit_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2879 {
2880  switch(msg)
2881  {
2882  case U8G_DEV_MSG_INIT:
2885  break;
2886  case U8G_DEV_MSG_STOP:
2887  break;
2888  case U8G_DEV_MSG_PAGE_NEXT:
2889  {
2890  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2891  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
2892  u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
2893  u8g_SetAddress(u8g, dev, 1); /* data mode */
2894  if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
2895  return 0;
2896  u8g_SetChipSelect(u8g, dev, 0);
2897  }
2898  break;
2899  case U8G_DEV_MSG_SLEEP_ON:
2900  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
2901  return 1;
2902  case U8G_DEV_MSG_SLEEP_OFF:
2903  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
2904  return 1;
2905  }
2906  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
2907 }
2908 
2909 uint8_t u8g_dev_sh1106_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2910 {
2911  switch(msg)
2912  {
2913  case U8G_DEV_MSG_INIT:
2916  break;
2917  case U8G_DEV_MSG_STOP:
2918  break;
2919  case U8G_DEV_MSG_PAGE_NEXT:
2920  {
2921  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2922  u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
2923  u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
2924  u8g_SetAddress(u8g, dev, 1); /* data mode */
2925  if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
2926  return 0;
2927  u8g_SetChipSelect(u8g, dev, 0);
2928  }
2929  break;
2930  case U8G_DEV_MSG_SLEEP_ON:
2931  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
2932  return 1;
2933  case U8G_DEV_MSG_SLEEP_OFF:
2934  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
2935  return 1;
2936  }
2937  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
2938 }
2939 
2940 
2941 uint8_t u8g_dev_ssd1306_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2942 {
2943  switch(msg)
2944  {
2945  case U8G_DEV_MSG_INIT:
2948  break;
2949  case U8G_DEV_MSG_STOP:
2950  break;
2951  case U8G_DEV_MSG_PAGE_NEXT:
2952  {
2953  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2954 
2955  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
2956  u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
2957  u8g_SetAddress(u8g, dev, 1); /* data mode */
2958  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf);
2959  u8g_SetChipSelect(u8g, dev, 0);
2960 
2961  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
2962  u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
2963  u8g_SetAddress(u8g, dev, 1); /* data mode */
2964  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
2965  u8g_SetChipSelect(u8g, dev, 0);
2966  }
2967  break;
2968  case U8G_DEV_MSG_SLEEP_ON:
2969  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
2970  return 1;
2971  case U8G_DEV_MSG_SLEEP_OFF:
2972  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
2973  return 1;
2974  }
2975  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
2976 }
2977 
2978 uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
2979 {
2980  switch(msg)
2981  {
2982  case U8G_DEV_MSG_INIT:
2985  break;
2986  case U8G_DEV_MSG_STOP:
2987  break;
2988  case U8G_DEV_MSG_PAGE_NEXT:
2989  {
2990  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
2991 
2992  u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
2993  u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
2994  u8g_SetAddress(u8g, dev, 1); /* data mode */
2995  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf);
2996  u8g_SetChipSelect(u8g, dev, 0);
2997 
2998  u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
2999  u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
3000  u8g_SetAddress(u8g, dev, 1); /* data mode */
3001  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
3002  u8g_SetChipSelect(u8g, dev, 0);
3003  }
3004  break;
3005  case U8G_DEV_MSG_SLEEP_ON:
3006  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
3007  return 1;
3008  case U8G_DEV_MSG_SLEEP_OFF:
3009  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
3010  return 1;
3011  }
3012  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
3013 }
3014 
3015 
3016 
3017 
3018 U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
3019 U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
3021 
3022 U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
3023 U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
3024 U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
3025 
3026 
3027 uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
3028 u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
3032 
3033 
3034 U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
3035 U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
3036 U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
3037 
3038 uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
3039 u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
3043 
3044 
3045 // ================ u8g_font.c ===================
3046 
3047 /*
3048 
3049  u8g_font.c
3050 
3051  U8G Font High Level Interface
3052 
3053  Universal 8bit Graphics Library
3054 
3055  Copyright (c) 2011, olikraus@gmail.com
3056  All rights reserved.
3057 
3058  Redistribution and use in source and binary forms, with or without modification,
3059  are permitted provided that the following conditions are met:
3060 
3061  * Redistributions of source code must retain the above copyright notice, this list
3062  of conditions and the following disclaimer.
3063 
3064  * Redistributions in binary form must reproduce the above copyright notice, this
3065  list of conditions and the following disclaimer in the documentation and/or other
3066  materials provided with the distribution.
3067 
3068  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
3069  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
3070  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3071  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3072  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
3073  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3074  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
3075  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3076  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3077  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3078  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3079  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
3080  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3081 
3082 
3083 */
3084 
3085 
3086 /* font api */
3087 
3088 /* pointer to the start adress of the glyph, points to progmem area */
3089 typedef void * u8g_glyph_t;
3090 
3091 /* size of the font data structure, there is no struct or class... */
3092 #define U8G_FONT_DATA_STRUCT_SIZE 17
3093 
3094 /*
3095  ... instead the fields of the font data structure are accessed directly by offset
3096  font information
3097  offset
3098  0 font format
3099  1 FONTBOUNDINGBOX width unsigned
3100  2 FONTBOUNDINGBOX height unsigned
3101  3 FONTBOUNDINGBOX x-offset signed
3102  4 FONTBOUNDINGBOX y-offset signed
3103  5 capital A height unsigned
3104  6 start 'A'
3105  8 start 'a'
3106  10 encoding start
3107  11 encoding end
3108  12 descent 'g' negative: below baseline
3109  13 font max ascent
3110  14 font min decent negative: below baseline
3111  15 font xascent
3112  16 font xdecent negative: below baseline
3113 
3114 */
3115 
3116 /* use case: What is the width and the height of the minimal box into which string s fints? */
3117 void u8g_font_GetStrSize(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
3118 void u8g_font_GetStrSizeP(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
3119 
3120 /* use case: lower left edge of a minimal box is known, what is the correct x, y position for the string draw procedure */
3121 void u8g_font_AdjustXYToDraw(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
3122 void u8g_font_AdjustXYToDrawP(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
3123 
3124 /* use case: Baseline origin known, return minimal box */
3125 void u8g_font_GetStrMinBox(u8g_t *u8g, const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
3126 
3127 /* procedures */
3128 
3129 /*========================================================================*/
3130 /* low level byte and word access */
3131 
3132 /* removed NOINLINE, because it leads to smaller code, might also be faster */
3133 //static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
3134 static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset)
3135 {
3136  font += offset;
3137  return u8g_pgm_read( (u8g_pgm_uint8_t *)font );
3138 }
3139 
3140 static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
3141 static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset)
3142 {
3143  uint16_t pos;
3144  font += offset;
3145  pos = u8g_pgm_read( (u8g_pgm_uint8_t *)font );
3146  font++;
3147  pos <<= 8;
3148  pos += u8g_pgm_read( (u8g_pgm_uint8_t *)font);
3149  return pos;
3150 }
3151 
3152 /*========================================================================*/
3153 /* direct access on the font */
3154 
3155 static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
3156 static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font)
3157 {
3158  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 0);
3159 }
3160 
3161 static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
3162 static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font)
3163 {
3164  switch(u8g_font_GetFormat((const u8g_fntpgm_uint8_t*)font))
3165  {
3166  case 0: return 6;
3167  case 1: return 3;
3168  case 2: return 6;
3169  }
3170  return 3;
3171 }
3172 
3173 static uint8_t u8g_font_GetBBXWidth(const void *font)
3174 {
3175  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 1);
3176 }
3177 
3178 static uint8_t u8g_font_GetBBXHeight(const void *font)
3179 {
3180  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 2);
3181 }
3182 
3183 static int8_t u8g_font_GetBBXOffX(const void *font)
3184 {
3185  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 3);
3186 }
3187 
3188 static int8_t u8g_font_GetBBXOffY(const void *font)
3189 {
3190  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 4);
3191 }
3192 
3193 uint8_t u8g_font_GetCapitalAHeight(const void *font)
3194 {
3195  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 5);
3196 }
3197 
3198 uint16_t u8g_font_GetEncoding65Pos(const void *font) U8G_NOINLINE;
3199 uint16_t u8g_font_GetEncoding65Pos(const void *font)
3200 {
3201  return u8g_font_get_word((const u8g_fntpgm_uint8_t*)font, 6);
3202 }
3203 
3204 uint16_t u8g_font_GetEncoding97Pos(const void *font) U8G_NOINLINE;
3205 uint16_t u8g_font_GetEncoding97Pos(const void *font)
3206 {
3207  return u8g_font_get_word((const u8g_fntpgm_uint8_t*)font, 8);
3208 }
3209 
3210 uint8_t u8g_font_GetFontStartEncoding(const void *font)
3211 {
3212  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 10);
3213 }
3214 
3215 uint8_t u8g_font_GetFontEndEncoding(const void *font)
3216 {
3217  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 11);
3218 }
3219 
3220 int8_t u8g_font_GetLowerGDescent(const void *font)
3221 {
3222  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 12);
3223 }
3224 
3225 int8_t u8g_font_GetFontAscent(const void *font)
3226 {
3227  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 13);
3228 }
3229 
3230 int8_t u8g_font_GetFontDescent(const void *font)
3231 {
3232  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 14);
3233 }
3234 
3235 int8_t u8g_font_GetFontXAscent(const void *font)
3236 {
3237  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 15);
3238 }
3239 
3240 int8_t u8g_font_GetFontXDescent(const void *font)
3241 {
3242  return u8g_font_get_byte((const u8g_fntpgm_uint8_t*)font, 16);
3243 }
3244 
3245 
3246 /* return the data start for a font and the glyph pointer */
3247 static uint8_t *u8g_font_GetGlyphDataStart(const void *font, u8g_glyph_t g)
3248 {
3249  return ((u8g_fntpgm_uint8_t *)g) + u8g_font_GetFontGlyphStructureSize((const u8g_fntpgm_uint8_t*)font);
3250 }
3251 
3252 /* calculate the overall length of the font, only used to create the picture for the google wiki */
3253 size_t u8g_font_GetSize(const void *font)
3254 {
3255  uint8_t *p = (uint8_t *)(font);
3256  uint8_t font_format = u8g_font_GetFormat((const u8g_fntpgm_uint8_t*)font);
3257  uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize((const u8g_fntpgm_uint8_t*)font);
3258  uint8_t start, end;
3259  uint8_t i;
3260  uint8_t mask = 255;
3261 
3262  start = u8g_font_GetFontStartEncoding(font);
3263  end = u8g_font_GetFontEndEncoding(font);
3264 
3265  if ( font_format == 1 )
3266  mask = 15;
3267 
3268  p += U8G_FONT_DATA_STRUCT_SIZE; /* skip font general information */
3269 
3270  i = start;
3271  for(;;)
3272  {
3273  if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
3274  {
3275  p += 1;
3276  }
3277  else
3278  {
3279  p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
3280  p += data_structure_size;
3281  }
3282  if ( i == end )
3283  break;
3284  i++;
3285  }
3286 
3287  return p - (uint8_t *)font;
3288 }
3289 
3290 /*========================================================================*/
3291 /* u8g interface, font access */
3292 
3294 {
3295  return u8g_font_GetBBXWidth(u8g->font);
3296 }
3297 
3299 {
3300  return u8g_font_GetBBXHeight(u8g->font);
3301 }
3302 
3305 {
3306  return u8g_font_GetBBXOffX(u8g->font);
3307 }
3308 
3311 {
3312  return u8g_font_GetBBXOffY(u8g->font);
3313 }
3314 
3317 {
3318  return u8g_font_GetCapitalAHeight(u8g->font);
3319 }
3320 
3321 /*========================================================================*/
3322 /* glyph handling */
3323 
3324 static void u8g_CopyGlyphDataToCache(u8g_t *u8g, u8g_glyph_t g)
3325 {
3326  uint8_t tmp;
3327  switch( u8g_font_GetFormat(u8g->font) )
3328  {
3329  case 0:
3330  case 2:
3331  /*
3332  format 0
3333  glyph information
3334  offset
3335  0 BBX width unsigned
3336  1 BBX height unsigned
3337  2 data size unsigned (BBX width + 7)/8 * BBX height
3338  3 DWIDTH signed
3339  4 BBX xoffset signed
3340  5 BBX yoffset signed
3341  byte 0 == 255 indicates empty glyph
3342  */
3343  u8g->glyph_width = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
3344  u8g->glyph_height = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
3345  u8g->glyph_dx = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 3 );
3346  u8g->glyph_x = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 4 );
3347  u8g->glyph_y = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 5 );
3348  break;
3349  case 1:
3350  default:
3351  /*
3352 format 1
3353  0 BBX xoffset signed --> upper 4 Bit
3354  0 BBX yoffset signed --> lower 4 Bit
3355  1 BBX width unsigned --> upper 4 Bit
3356  1 BBX height unsigned --> lower 4 Bit
3357  2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit
3358  2 DWIDTH signed --> upper 4 Bit
3359  byte 0 == 255 indicates empty glyph
3360  */
3361 
3362  tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
3363  u8g->glyph_y = tmp & 15;
3364  u8g->glyph_y-=2;
3365  tmp >>= 4;
3366  u8g->glyph_x = tmp;
3367 
3368  tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
3369  u8g->glyph_height = tmp & 15;
3370  tmp >>= 4;
3371  u8g->glyph_width = tmp;
3372 
3373  tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 2 );
3374  tmp >>= 4;
3375  u8g->glyph_dx = tmp;
3376 
3377 
3378  break;
3379  }
3380 }
3381 
3382 //void u8g_FillEmptyGlyphCache(u8g_t *u8g) U8G_NOINLINE;
3384 {
3385  u8g->glyph_dx = 0;
3386  u8g->glyph_width = 0;
3387  u8g->glyph_height = 0;
3388  u8g->glyph_x = 0;
3389  u8g->glyph_y = 0;
3390 }
3391 
3392 /*
3393  Find (with some speed optimization) and return a pointer to the glyph data structure
3394  Also uncompress (format 1) and copy the content of the data structure to the u8g structure
3395 */
3396 u8g_glyph_t u8g_GetGlyph(u8g_t *u8g, uint8_t requested_encoding)
3397 {
3398  uint8_t *p = (uint8_t *)(u8g->font);
3399  uint8_t font_format = u8g_font_GetFormat(u8g->font);
3400  uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize(u8g->font);
3401  uint8_t start, end;
3402  uint16_t pos;
3403  uint8_t i;
3404  uint8_t mask = 255;
3405 
3406  if ( font_format == 1 )
3407  mask = 15;
3408 
3409  start = u8g_font_GetFontStartEncoding(u8g->font);
3410  end = u8g_font_GetFontEndEncoding(u8g->font);
3411 
3412  pos = u8g_font_GetEncoding97Pos(u8g->font);
3413  if ( requested_encoding >= 97 && pos > 0 )
3414  {
3415  p+= pos;
3416  start = 97;
3417  }
3418  else
3419  {
3420  pos = u8g_font_GetEncoding65Pos(u8g->font);
3421  if ( requested_encoding >= 65 && pos > 0 )
3422  {
3423  p+= pos;
3424  start = 65;
3425  }
3426  else
3427  p += U8G_FONT_DATA_STRUCT_SIZE; /* skip font general information */
3428  }
3429 
3430  if ( requested_encoding > end )
3431  {
3433  return NULL; /* not found */
3434  }
3435 
3436  i = start;
3437  if ( i <= end )
3438  {
3439  for(;;)
3440  {
3441  if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
3442  {
3443  p += 1;
3444  }
3445  else
3446  {
3447  if ( i == requested_encoding )
3448  {
3449  u8g_CopyGlyphDataToCache(u8g, p);
3450  return p;
3451  }
3452  p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
3453  p += data_structure_size;
3454  }
3455  if ( i == end )
3456  break;
3457  i++;
3458  }
3459  }
3460 
3462 
3463  return NULL;
3464 }
3465 
3466 uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding)
3467 {
3468  if ( u8g_GetGlyph(u8g, requested_encoding) != NULL )
3469  return 1;
3470  return 0;
3471 }
3472 
3473 int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding)
3474 {
3475  if ( u8g_GetGlyph(u8g, requested_encoding) == NULL )
3476  return 0; /* should never happen, so return something */
3477  return u8g->glyph_dx;
3478 }
3479 
3480 
3481 /*========================================================================*/
3482 /* glyph drawing procedures */
3483 
3484 #ifdef OBSOLETE
3485 /*
3486  Draw a glyph
3487  x,y: left baseline position of the glyph
3488 */
3489 int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
3490 {
3491  u8g_glyph_t g;
3492  uint8_t w, h, i, j;
3493  const u8g_pgm_uint8_t *data;
3494  uint8_t bytes_per_line;
3495  u8g_uint_t ix, iy;
3496 
3497  g = u8g_GetGlyph(u8g, encoding);
3498  if ( g == NULL )
3499  return 0;
3500  w = u8g->glyph_width;
3501  h = u8g->glyph_height;
3502 
3503  bytes_per_line = w;
3504  bytes_per_line += 7;
3505  bytes_per_line /= 8;
3506 
3507  data = u8g_font_GetGlyphDataStart(u8g->font, g);
3508 
3509  switch(dir)
3510  {
3511  case 0:
3512  x += u8g->glyph_x;
3513  y -= u8g->glyph_y;
3514  y--;
3515  //u8g_DrawFrame(u8g, x, y-h+1, w, h);
3516  if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
3517  return u8g->glyph_dx;
3518 
3519  iy = y;
3520  iy -= h;
3521  iy++;
3522 
3523  for( j = 0; j < h; j++ )
3524  {
3525  ix = x;
3526  for( i = 0; i < bytes_per_line; i++ )
3527  {
3528  u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
3529  data++;
3530  ix+=8;
3531  }
3532  iy++;
3533  }
3534  break;
3535  case 1:
3536  x += u8g->glyph_y;
3537  x++;
3538  y += u8g->glyph_x;
3539  //printf("enc %d, dir %d, x %d, y %d, w %d, h %d\n", encoding, dir, x, y, w, h);
3540  //u8g_DrawFrame(u8g, x, y, h, w);
3541  if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
3542  return u8g->glyph_dx;
3543 
3544  ix = x;
3545  ix += h;
3546  ix--;
3547  for( j = 0; j < h; j++ )
3548  {
3549  iy = y;
3550  for( i = 0; i < bytes_per_line; i++ )
3551  {
3552  u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
3553  data++;
3554  iy+=8;
3555  }
3556  ix--;
3557  }
3558  break;
3559  case 2:
3560  x -= u8g->glyph_x;
3561  y += u8g->glyph_y;
3562  y++;
3563  if ( u8g_IsBBXIntersection(u8g, x-w-1, y, w, h) == 0 )
3564  return u8g->glyph_dx;
3565 
3566  iy = y;
3567  iy += h;
3568  iy--;
3569  for( j = 0; j < h; j++ )
3570  {
3571  ix = x;
3572  for( i = 0; i < bytes_per_line; i++ )
3573  {
3574  u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
3575  data++;
3576  ix-=8;
3577  }
3578  iy--;
3579  }
3580  break;
3581  case 3:
3582  x -= u8g->glyph_y;
3583  x--;
3584  y -= u8g->glyph_x;
3585 
3586  if ( u8g_IsBBXIntersection(u8g, x-h-1, y-w-1, h, w) == 0 )
3587  return u8g->glyph_dx;
3588 
3589  ix = x;
3590  ix -= h;
3591  ix++;
3592 
3593  for( j = 0; j < h; j++ )
3594  {
3595  iy = y;
3596  for( i = 0; i < bytes_per_line; i++ )
3597  {
3598  u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
3599  data++;
3600  iy-=8;
3601  }
3602  ix++;
3603  }
3604  break;
3605  }
3606  return u8g->glyph_dx;
3607 }
3608 #endif
3609 
3610 int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3611 {
3612  const u8g_pgm_uint8_t *data;
3613  uint8_t w, h;
3614  uint8_t i, j;
3615  u8g_uint_t ix, iy;
3616 
3617  {
3618  u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
3619  if ( g == NULL )
3620  return 0;
3621  data = u8g_font_GetGlyphDataStart(u8g->font, g);
3622  }
3623 
3624  w = u8g->glyph_width;
3625  h = u8g->glyph_height;
3626 
3627  x += u8g->glyph_x;
3628  y -= u8g->glyph_y;
3629  y--;
3630 
3631  if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
3632  return u8g->glyph_dx;
3633 
3634  /* now, w is reused as bytes per line */
3635  w += 7;
3636  w /= 8;
3637 
3638  iy = y;
3639  iy -= h;
3640  iy++;
3641 
3642  for( j = 0; j < h; j++ )
3643  {
3644  ix = x;
3645  for( i = 0; i < w; i++ )
3646  {
3647  u8g_Draw8Pixel(u8g, ix, iy, 0, u8g_pgm_read(data));
3648  data++;
3649  ix+=8;
3650  }
3651  iy++;
3652  }
3653  return u8g->glyph_dx;
3654 }
3655 
3656 int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3657 {
3658  y += u8g->font_calc_vref(u8g);
3659  return u8g_draw_glyph(u8g, x, y, encoding);
3660 }
3661 
3662 int8_t u8g_draw_glyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3663 {
3664  const u8g_pgm_uint8_t *data;
3665  uint8_t w, h;
3666  uint8_t i, j;
3667  u8g_uint_t ix, iy;
3668 
3669  {
3670  u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
3671  if ( g == NULL )
3672  return 0;
3673  data = u8g_font_GetGlyphDataStart(u8g->font, g);
3674  }
3675 
3676  w = u8g->glyph_width;
3677  h = u8g->glyph_height;
3678 
3679  x += u8g->glyph_y;
3680  x++;
3681  y += u8g->glyph_x;
3682 
3683  if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
3684  return u8g->glyph_dx;
3685 
3686  /* now, w is reused as bytes per line */
3687  w += 7;
3688  w /= 8;
3689 
3690  ix = x;
3691  ix += h;
3692  ix--;
3693  for( j = 0; j < h; j++ )
3694  {
3695  iy = y;
3696  for( i = 0; i < w; i++ )
3697  {
3698  u8g_Draw8Pixel(u8g, ix, iy, 1, u8g_pgm_read(data));
3699  data++;
3700  iy+=8;
3701  }
3702  ix--;
3703  }
3704  return u8g->glyph_dx;
3705 }
3706 
3707 int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3708 {
3709  x -= u8g->font_calc_vref(u8g);
3710  return u8g_draw_glyph90(u8g, x, y, encoding);
3711 }
3712 
3713 
3714 int8_t u8g_draw_glyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3715 {
3716  const u8g_pgm_uint8_t *data;
3717  uint8_t w, h;
3718  uint8_t i, j;
3719  u8g_uint_t ix, iy;
3720 
3721  {
3722  u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
3723  if ( g == NULL )
3724  return 0;
3725  data = u8g_font_GetGlyphDataStart(u8g->font, g);
3726  }
3727 
3728  w = u8g->glyph_width;
3729  h = u8g->glyph_height;
3730 
3731  x -= u8g->glyph_x;
3732  y += u8g->glyph_y;
3733  y++;
3734 
3735  if ( u8g_IsBBXIntersection(u8g, x-(w-1), y, w, h) == 0 )
3736  return u8g->glyph_dx;
3737 
3738  /* now, w is reused as bytes per line */
3739  w += 7;
3740  w /= 8;
3741 
3742  iy = y;
3743  iy += h;
3744  iy--;
3745  for( j = 0; j < h; j++ )
3746  {
3747  ix = x;
3748  for( i = 0; i < w; i++ )
3749  {
3750  u8g_Draw8Pixel(u8g, ix, iy, 2, u8g_pgm_read(data));
3751  data++;
3752  ix-=8;
3753  }
3754  iy--;
3755  }
3756  return u8g->glyph_dx;
3757 }
3758 
3759 int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3760 {
3761  y -= u8g->font_calc_vref(u8g);
3762  return u8g_draw_glyph180(u8g, x, y, encoding);
3763 }
3764 
3765 
3766 int8_t u8g_draw_glyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3767 {
3768  const u8g_pgm_uint8_t *data;
3769  uint8_t w, h;
3770  uint8_t i, j;
3771  u8g_uint_t ix, iy;
3772 
3773  {
3774  u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
3775  if ( g == NULL )
3776  return 0;
3777  data = u8g_font_GetGlyphDataStart(u8g->font, g);
3778  }
3779 
3780  w = u8g->glyph_width;
3781  h = u8g->glyph_height;
3782 
3783  x -= u8g->glyph_y;
3784  x--;
3785  y -= u8g->glyph_x;
3786 
3787  if ( u8g_IsBBXIntersection(u8g, x-(h-1), y-(w-1), h, w) == 0 )
3788  return u8g->glyph_dx;
3789 
3790 
3791  /* now, w is reused as bytes per line */
3792  w += 7;
3793  w /= 8;
3794 
3795  ix = x;
3796  ix -= h;
3797  ix++;
3798 
3799  for( j = 0; j < h; j++ )
3800  {
3801  iy = y;
3802  for( i = 0; i < w; i++ )
3803  {
3804  u8g_Draw8Pixel(u8g, ix, iy, 3, u8g_pgm_read(data));
3805  data++;
3806  iy-=8;
3807  }
3808  ix++;
3809  }
3810  return u8g->glyph_dx;
3811 }
3812 
3813 int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
3814 {
3815  x += u8g->font_calc_vref(u8g);
3816  return u8g_draw_glyph270(u8g, x, y, encoding);
3817 }
3818 
3819 
3820 
3821 #ifdef OBSOLETE
3822 /*
3823  Draw a glyph
3824  x,y: lower left corner of the font bounding box
3825 */
3826 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
3827 {
3828  /* TODO: apply "dir" */
3829  x -= u8g_GetFontBBXOffX(u8g);
3830  y += u8g_GetFontBBXOffY(u8g);
3831  return u8g_DrawGlyphDir(u8g, x, y, dir, encoding);
3832 }
3833 #endif
3834 
3835 /*========================================================================*/
3836 /* string drawing procedures */
3837 
3838 
3839 u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
3840 {
3841  u8g_uint_t t = 0;
3842  int8_t d;
3843 
3844  //u8g_uint_t u8g_GetStrWidth(u8g, s);
3845  //u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
3846 
3847  y += u8g->font_calc_vref(u8g);
3848 
3849  while( *s != '\0' )
3850  {
3851  d = u8g_draw_glyph(u8g, x, y, *s);
3852  x += d;
3853  t += d;
3854  s++;
3855  }
3856  return t;
3857 }
3858 
3859 u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
3860 {
3861  u8g_uint_t t = 0;
3862  int8_t d;
3863 
3864  x -= u8g->font_calc_vref(u8g);
3865 
3866  while( *s != '\0' )
3867  {
3868  d = u8g_draw_glyph90(u8g, x, y, *s);
3869  y += d;
3870  t += d;
3871  s++;
3872  }
3873  return t;
3874 }
3875 
3876 u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
3877 {
3878  u8g_uint_t t = 0;
3879  int8_t d;
3880 
3881  y -= u8g->font_calc_vref(u8g);
3882 
3883  while( *s != '\0' )
3884  {
3885  d = u8g_draw_glyph180(u8g, x, y, *s);
3886  x -= d;
3887  t += d;
3888  s++;
3889  }
3890  return t;
3891 }
3892 
3893 u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
3894 {
3895  u8g_uint_t t = 0;
3896  int8_t d;
3897 
3898  x += u8g->font_calc_vref(u8g);
3899 
3900  while( *s != '\0' )
3901  {
3902  d = u8g_draw_glyph270(u8g, x, y, *s);
3903  y -= d;
3904  t += d;
3905  s++;
3906  }
3907  return t;
3908 }
3909 
3910 u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
3911 {
3912  switch(dir)
3913  {
3914  case 0:
3915  return u8g_DrawStr(u8g, x, y, s);
3916  case 1:
3917  return u8g_DrawStr90(u8g, x, y, s);
3918  case 2:
3919  return u8g_DrawStr180(u8g, x, y, s);
3920  case 3:
3921  return u8g_DrawStr270(u8g, x, y, s);
3922  }
3923  return 0;
3924 }
3925 
3926 u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
3927 {
3928  u8g_uint_t t = 0;
3929  int8_t d;
3930  uint8_t c;
3931 
3932  y += u8g->font_calc_vref(u8g);
3933 
3934  for(;;)
3935  {
3936  c = u8g_pgm_read(s);
3937  if ( c == '\0' )
3938  break;
3939  d = u8g_draw_glyph(u8g, x, y, c);
3940  x += d;
3941  t += d;
3942  s++;
3943  }
3944  return t;
3945 }
3946 
3947 u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
3948 {
3949  u8g_uint_t t = 0;
3950  int8_t d;
3951 
3952  x -= u8g->font_calc_vref(u8g);
3953 
3954  while( *s != '\0' )
3955  {
3956  d = u8g_DrawGlyph90(u8g, x, y, u8g_pgm_read(s));
3957  y += d;
3958  t += d;
3959  s++;
3960  }
3961  return t;
3962 }
3963 
3964 u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
3965 {
3966  u8g_uint_t t = 0;
3967  int8_t d;
3968 
3969  y -= u8g->font_calc_vref(u8g);
3970 
3971  while( *s != '\0' )
3972  {
3973  d = u8g_DrawGlyph180(u8g, x, y, u8g_pgm_read(s));
3974  x -= d;
3975  t += d;
3976  s++;
3977  }
3978  return t;
3979 }
3980 
3981 u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
3982 {
3983  u8g_uint_t t = 0;
3984  int8_t d;
3985 
3986  x += u8g->font_calc_vref(u8g);
3987 
3988  while( *s != '\0' )
3989  {
3990  d = u8g_DrawGlyph270(u8g, x, y, u8g_pgm_read(s));
3991  y -= d;
3992  t += d;
3993  s++;
3994  }
3995  return t;
3996 }
3997 
3998 u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
3999 {
4000  x -= u8g_GetFontBBXOffX(u8g);
4001  y += u8g_GetFontBBXOffY(u8g);
4002  return u8g_DrawStrDir(u8g, x, y, dir, s);
4003 }
4004 
4005 /* still used by picgen.c, dir argument is ignored */
4006 int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
4007 {
4008  x -= u8g_GetFontBBXOffX(u8g);
4009  y += u8g_GetFontBBXOffY(u8g);
4010  u8g_draw_glyph(u8g, x, y, encoding);
4011  return 0;
4012 }
4013 
4014 
4015 /*========================================================================*/
4016 /* set ascent/descent for reference point calculation */
4017 
4019 {
4020  uint16_t ls;
4021  if ( u8g->font == NULL )
4022  return;
4024  {
4027  }
4028  else if ( u8g->font_height_mode == U8G_FONT_HEIGHT_MODE_XTEXT )
4029  {
4032  }
4033  else
4034  {
4037  }
4038 
4039  ls = u8g->font_ref_ascent - u8g->font_ref_descent;
4040  if ( u8g->font_line_spacing_factor != 64 )
4041  {
4042  ls &= 255;
4043  ls *= u8g->font_line_spacing_factor;
4044  ls >>= 6;
4045  }
4046  u8g->line_spacing = ls;
4047 }
4048 
4050 {
4052  u8g_UpdateRefHeight(u8g);
4053 }
4054 
4056 {
4058  u8g_UpdateRefHeight(u8g);
4059 }
4060 
4061 
4063 {
4065  u8g_UpdateRefHeight(u8g);
4066 }
4067 
4068 /* factor = 64: linespaceing == ascent and descent */
4069 void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor)
4070 {
4071  u8g->font_line_spacing_factor = factor;
4072  u8g_UpdateRefHeight(u8g);
4073 }
4074 
4075 
4076 
4077 /*========================================================================*/
4078 /* callback procedures to correct the y position */
4079 
4081 {
4082  return 0;
4083 }
4084 
4086 {
4088 }
4089 
4090 
4092 {
4093  /* y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent); */
4094  return (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent);
4095 }
4096 
4098 {
4100 }
4101 
4103 {
4104  u8g_uint_t tmp;
4105  /* reference pos is one pixel above the upper edge of the reference glyph */
4106 
4107  /*
4108  y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
4109  y++;
4110  */
4111  tmp = (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
4112  tmp++;
4113  return tmp;
4114 }
4115 
4117 {
4119 }
4120 
4122 {
4123  int8_t tmp;
4124  tmp = u8g->font_ref_ascent;
4125  tmp -= u8g->font_ref_descent;
4126  tmp /= 2;
4127  tmp += u8g->font_ref_descent;
4128  /* y += (u8g_uint_t)(u8g_int_t)(tmp); */
4129  return tmp;
4130 }
4131 
4133 {
4135 }
4136 
4137 /*========================================================================*/
4138 /* string pixel width calculation */
4139 
4140 char u8g_font_get_char(const void *s)
4141 {
4142  return *(const char *)(s);
4143 }
4144 
4145 char u8g_font_get_charP(const void *s)
4146 {
4147  return u8g_pgm_read(s);
4148 }
4149 
4150 typedef char (*u8g_font_get_char_fn)(const void *s);
4151 
4152 
4153 u8g_uint_t u8g_font_calc_str_pixel_width(u8g_t *u8g, const char *s, u8g_font_get_char_fn get_char )
4154 {
4155  u8g_uint_t w;
4156  uint8_t enc;
4157 
4158  /* reset the total minimal width to zero, this will be expanded during calculation */
4159  w = 0;
4160 
4161  enc = get_char(s);
4162 
4163  /* check for empty string, width is already 0 */
4164  if ( enc == '\0' )
4165  {
4166  return w;
4167  }
4168 
4169  /* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
4170  /* if *s is not inside the font, then the cached parameters of the glyph are all zero */
4171  u8g_GetGlyph(u8g, enc);
4172 
4173  /* strlen(s) == 1: width = width(s[0]) */
4174  /* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
4175  /* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
4176 
4177  /* assume that the string has size 2 or more, than start with negative offset-x */
4178  /* for string with size 1, this will be nullified after the loop */
4179  w = -u8g->glyph_x;
4180  for(;;)
4181  {
4182 
4183  /* check and stop if the end of the string is reached */
4184  s++;
4185  if ( get_char(s) == '\0' )
4186  break;
4187 
4188  /* if there are still more characters, add the delta to the next glyph */
4189  w += u8g->glyph_dx;
4190 
4191  /* store the encoding in a local variable, used also after the for(;;) loop */
4192  enc = get_char(s);
4193 
4194  /* load the next glyph information */
4195  u8g_GetGlyph(u8g, enc);
4196  }
4197 
4198  /* finally calculate the width of the last char */
4199  /* here is another exception, if the last char is a black, use the dx value instead */
4200  if ( enc != ' ' )
4201  {
4202  /* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
4203  w += u8g->glyph_width;
4204  w += u8g->glyph_x;
4205  }
4206  else
4207  {
4208  w += u8g->glyph_dx;
4209  }
4210 
4211 
4212  return w;
4213 }
4214 
4215 u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s)
4216 {
4218 }
4219 
4220 u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
4221 {
4222  return u8g_font_calc_str_pixel_width(u8g, (const char *)s, u8g_font_get_charP);
4223 }
4224 
4225 int8_t u8g_GetStrX(u8g_t *u8g, const char *s)
4226 {
4227  u8g_GetGlyph(u8g, *s);
4228  return u8g->glyph_x;
4229 }
4230 
4231 int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
4232 {
4233  u8g_GetGlyph(u8g, u8g_pgm_read(s));
4234  return u8g->glyph_x;
4235 }
4236 
4237 /*========================================================================*/
4238 /* string width calculation */
4239 
4240 u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s)
4241 {
4242  u8g_uint_t w;
4243  uint8_t encoding;
4244 
4245  /* reset the total width to zero, this will be expanded during calculation */
4246  w = 0;
4247 
4248  for(;;)
4249  {
4250  encoding = *s;
4251  if ( encoding == 0 )
4252  break;
4253 
4254  /* load glyph information */
4255  u8g_GetGlyph(u8g, encoding);
4256  w += u8g->glyph_dx;
4257 
4258  /* goto next char */
4259  s++;
4260  }
4261 
4262  return w;
4263 }
4264 
4265 
4266 u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
4267 {
4268  u8g_uint_t w;
4269  uint8_t encoding;
4270 
4271  /* reset the total width to zero, this will be expanded during calculation */
4272  w = 0;
4273 
4274  for(;;)
4275  {
4276  encoding = u8g_pgm_read(s);
4277  if ( encoding == 0 )
4278  break;
4279 
4280  /* load glyph information */
4281  u8g_GetGlyph(u8g, encoding);
4282  w += u8g->glyph_dx;
4283 
4284  /* goto next char */
4285  s++;
4286  }
4287 
4288  return w;
4289 }
4290 
4291 
4292 /*========================================================================*/
4293 /* calculation of font/glyph/string characteristics */
4294 
4295 
4296 /*
4297  Description:
4298  Calculate parameter for the minimal bounding box on a given string
4299  Output
4300  buf->y_min extend of the lower left edge if the string below (y_min<0) or above (y_min>0) baseline (descent)
4301  buf->y_max extend of the upper left edge if the string below (y_min<0) or above (y_min>0) baseline (ascent)
4302  buf->w the width of the string
4303 */
4305 {
4306  int8_t y_min; /* descent */
4307  int8_t y_max; /* ascent */
4308  int8_t x, y; /* the reference point of the font (negated!) */
4309  u8g_uint_t w; /* width of the overall string */
4310 };
4312 
4313 static void u8g_font_calc_str_min_box(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
4314 {
4315  /* u8g_glyph_t g; */
4316  int8_t tmp;
4317 
4318  /* reset the total minimal width to zero, this will be expanded during calculation */
4319  buf->w = 0;
4320 
4321  /* check for empty string, width is already 0, but also reset y_min and y_max to 0 */
4322  if ( *s == '\0' )
4323  {
4324  buf->y_min = 0;
4325  buf->y_max = 0;
4326  buf->x = 0;
4327  buf->y = 0;
4328  return;
4329  }
4330 
4331  /* reset y_min to the largest possible value. Later we search for the smallest value */
4332  /* y_min contains the position [pixel] of the lower left edge of the glyph above (y_min>0) or below (y_min<0) baseline */
4333  buf->y_min = 127;
4334  /* reset y_max to the smallest possible value. Later we search for the highest value */
4335  /* y_max contains the position [pixel] of the upper left edge of the glyph above (y_max>0) or below (y_max<0) baseline */
4336  buf->y_max = -128;
4337 
4338  /* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
4339  u8g_GetGlyph(u8g, *s);
4340 
4341  /* strlen(s) == 1: width = width(s[0]) */
4342  /* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
4343  /* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
4344 
4345  /* assume that the string has size 2 or more, than start with negative offset-x */
4346  /* for string with size 1, this will be nullified after the loop */
4347  // buf->w = - u8g_font_GetGlyphBBXOffX(u8g->font, g);
4348  buf->w = - u8g->glyph_x;
4349 
4350  /* Also copy the position of the first glyph. This is the reference point of the string (negated) */
4351  buf->x = u8g->glyph_x;
4352  buf->y = u8g->glyph_y;
4353 
4354  for(;;)
4355  {
4356 
4357  /* calculated y position of the upper left corner (y_max) and lower left corner (y_min) of the string */
4358  /* relative to the base line */
4359 
4360  tmp = u8g->glyph_y;
4361  if ( buf->y_min > tmp )
4362  buf->y_min = tmp;
4363 
4364  tmp +=u8g->glyph_height;
4365  if ( buf->y_max < tmp )
4366  buf->y_max = tmp;
4367 
4368  /* check and stop if the end of the string is reached */
4369  s++;
4370  if ( *s == '\0' )
4371  break;
4372 
4373  /* if there are still more characters, add the delta to the next glyph */
4374  buf->w += u8g->glyph_dx;
4375 
4376  /* load the next glyph information */
4377  u8g_GetGlyph(u8g, *s);
4378  }
4379 
4380  /* finally calculate the width of the last char */
4381  /* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
4382  buf->w += u8g->glyph_width;
4383  // buf->w += u8g_font_GetGlyphBBXOffX(u8g->font, g);
4384 
4385  buf->w += u8g->glyph_x;
4386 }
4387 
4388 /* calculate minimal box */
4389 void u8g_font_box_min(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
4390 {
4391  u8g_font_calc_str_min_box(u8g, s, buf);
4392 }
4393 
4394 /* calculate gA box, but do not calculate the overall width */
4395 void u8g_font_box_left_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
4396 {
4397 
4398 }
4399 
4400 /* calculate gA box, including overall width */
4401 void u8g_font_box_all_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
4402 {
4403 
4404 }
4405 
4406 
4407 static void u8g_font_get_str_box_fill_args(u8g_t *u8g, const char *s, u8g_str_size_t *buf, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
4408 {
4409  /*
4410  u8g_glyph_t g;
4411  g =
4412  */
4413  u8g_GetGlyph(u8g, *s);
4414  *x += u8g->glyph_x;
4415  *width = buf->w;
4416  *y -= buf->y_max;
4417  /* +1 because y_max is a height, this compensates the next step */
4418  //*y += 1;
4419  /* because the reference point is one below the string, this compensates the previous step */
4420  //*y -= 1;
4421  *height = buf->y_max;
4422  *height -= buf->y_min;
4423 }
4424 
4425 
4426 void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
4427 {
4428  u8g_str_size_t buf;
4429 
4430  if ( *s == '\0' )
4431  {
4432  *width= 0;
4433  *height = 0;
4434  return;
4435  }
4436 
4437  u8g_font_calc_str_min_box(u8g, s, &buf);
4438  u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
4439 }
4440 
4441 
4442 void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
4443 {
4444  u8g_str_size_t buf;
4445  uint8_t cap_a;
4446 
4447  if ( *s == '\0' )
4448  {
4449  *width= 0;
4450  *height = 0;
4451  return;
4452  }
4453 
4454  cap_a = u8g_font_GetCapitalAHeight(u8g->font);
4455  u8g_font_calc_str_min_box(u8g, s, &buf);
4456  if ( buf.y_max < cap_a )
4457  buf.y_max = cap_a;
4458  u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
4459 }
4460 
4461 void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font)
4462 {
4463  if ( u8g->font != font )
4464  {
4465  u8g->font = font;
4466  u8g_UpdateRefHeight(u8g);
4468  }
4469 }
4470 
4471 /*========================================================================*/
4472 /* anti aliasing fonts */
4473 
4474 int8_t u8g_draw_aa_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
4475 {
4476  const u8g_pgm_uint8_t *data;
4477  uint8_t w, h;
4478  uint8_t i, j;
4479  u8g_uint_t ix, iy;
4480 
4481  {
4482  u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
4483  if ( g == NULL )
4484  return 0;
4485  data = u8g_font_GetGlyphDataStart(u8g->font, g);
4486  }
4487 
4488  w = u8g->glyph_width;
4489  h = u8g->glyph_height;
4490 
4491  x += u8g->glyph_x;
4492  y -= u8g->glyph_y;
4493  y--;
4494 
4495  if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
4496  return u8g->glyph_dx;
4497 
4498  /* now, w is reused as bytes per line */
4499  w += 3;
4500  w /= 4;
4501 
4502  iy = y;
4503  iy -= h;
4504  iy++;
4505 
4506  for( j = 0; j < h; j++ )
4507  {
4508  ix = x;
4509  for( i = 0; i < w; i++ )
4510  {
4511  u8g_Draw4TPixel(u8g, ix, iy, 0, u8g_pgm_read(data));
4512  data++;
4513  ix+=4;
4514  }
4515  iy++;
4516  }
4517  return u8g->glyph_dx;
4518 }
4519 
4520 int8_t u8g_DrawAAGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
4521 {
4522  y += u8g->font_calc_vref(u8g);
4523  return u8g_draw_aa_glyph(u8g, x, y, encoding);
4524 }
4525 
4526 u8g_uint_t u8g_DrawAAStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
4527 {
4528  u8g_uint_t t = 0;
4529  int8_t d;
4530 
4531  if ( u8g_font_GetFormat(u8g->font) != 2 )
4532  return 0;
4533  //u8g_uint_t u8g_GetStrWidth(u8g, s);
4534  //u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
4535 
4536  y += u8g->font_calc_vref(u8g);
4537 
4538  while( *s != '\0' )
4539  {
4540  d = u8g_draw_aa_glyph(u8g, x, y, *s);
4541  x += d;
4542  t += d;
4543  s++;
4544  }
4545  return t;
4546 }
4547 
4548 // ============== u8g_page.c ================
4549 
4550 /*
4551 
4552  u8g_page.c
4553 
4554  page helper functions, only called by the dev handler.
4555 
4556  Universal 8bit Graphics Library
4557 
4558  Copyright (c) 2011, olikraus@gmail.com
4559  All rights reserved.
4560 
4561  Redistribution and use in source and binary forms, with or without modification,
4562  are permitted provided that the following conditions are met:
4563 
4564  * Redistributions of source code must retain the above copyright notice, this list
4565  of conditions and the following disclaimer.
4566 
4567  * Redistributions in binary form must reproduce the above copyright notice, this
4568  list of conditions and the following disclaimer in the documentation and/or other
4569  materials provided with the distribution.
4570 
4571  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
4572  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
4573  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4574  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4575  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
4576  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4577  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4578  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4579  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4580  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4581  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4582  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
4583  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4584 
4585 
4586 */
4587 
4588 /*
4589  setup page count structure
4590  conditions: page_height <= total_height
4591 */
4592 void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
4593 {
4594  p->page_height = page_height;
4595  p->total_height = total_height;
4596  p->page = 0;
4597  u8g_page_First(p);
4598 }
4599 
4601 {
4602  p->page_y0 = 0;
4603  p->page_y1 = p->page_height;
4604  p->page_y1--;
4605  p->page = 0;
4606 }
4607 
4609 {
4610  register u8g_uint_t y1;
4611  p->page_y0 += p->page_height;
4612  if ( p->page_y0 >= p->total_height )
4613  return 0;
4614  p->page++;
4615  y1 = p->page_y1;
4616  y1 += p->page_height;
4617  if ( y1 >= p->total_height )
4618  {
4619  y1 = p->total_height;
4620  y1--;
4621  }
4622  p->page_y1 = y1;
4623 
4624  return 1;
4625 }
4626 
4627 // =============== u8g_clip.c ================
4628 
4629 /*
4630 
4631  u8g_clip.c
4632 
4633  procedures for clipping
4634  taken over from procs in u8g_pb.c
4635 
4636  Universal 8bit Graphics Library
4637 
4638  Copyright (c) 2012, olikraus@gmail.com
4639  All rights reserved.
4640 
4641  Redistribution and use in source and binary forms, with or without modification,
4642  are permitted provided that the following conditions are met:
4643 
4644  * Redistributions of source code must retain the above copyright notice, this list
4645  of conditions and the following disclaimer.
4646 
4647  * Redistributions in binary form must reproduce the above copyright notice, this
4648  list of conditions and the following disclaimer in the documentation and/or other
4649  materials provided with the distribution.
4650 
4651  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
4652  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
4653  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4654  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4655  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
4656  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4657  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4658  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4659  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4660  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4661  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4662  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
4663  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4664 
4665  Notes
4666 
4667  This is one of the most critical parts of u8glib. It must be fast, but still reliable.
4668  Based on the intersection program (see tools folder), there is minimized version of
4669  the condition for the intersaction test:
4670  minimized version
4671  ---1----0 1 b1 <= a2 && b1 > b2
4672  -----1--0 1 b2 >= a1 && b1 > b2
4673  ---1-1--- 1 b1 <= a2 && b2 >= a1
4674  It includes the assumption, that a1 <= a2 is always true (correct, because
4675  a1, a2 are the page dimensions.
4676 
4677  The direct implementation of the above result is done in:
4678  uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
4679  However, this is slower than a decision tree version:
4680  static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
4681  Also suprising is, that the macro implementation is slower than the inlined version.
4682 
4683  The decision tree is based on the expansion of the truth table.
4684 
4685 */
4686 
4687 
4688 #ifdef __GNUC__
4689 #define U8G_ALWAYS_INLINE __inline__ __attribute__((always_inline))
4690 #else
4691 #define U8G_ALWAYS_INLINE
4692  #endif
4693 
4694 /*
4695  intersection assumptions:
4696  a1 <= a2 is always true
4697 
4698  minimized version
4699  ---1----0 1 b1 <= a2 && b1 > b2
4700  -----1--0 1 b2 >= a1 && b1 > b2
4701  ---1-1--- 1 b1 <= a2 && b2 >= a1
4702  */
4703 
4704 #ifdef OLD_CODE_WHICH_IS_TOO_SLOW
4705 static uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
4706 {
4707  uint8_t c1, c2, c3, tmp;
4708  c1 = v0 <= a1;
4709  c2 = v1 >= a0;
4710  c3 = v0 > v1;
4711 
4712  tmp = c1;
4713  c1 &= c2;
4714  c2 &= c3;
4715  c3 &= tmp;
4716  c1 |= c2;
4717  c1 |= c3;
4718  return c1 & 1;
4719 }
4720 #endif
4721 
4722 #define U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1) ((uint8_t)( (v0) <= (a1) ) ? ( ( (v1) >= (a0) ) ? ( 1 ) : ( (v0) > (v1) ) ) : ( ( (v1) >= (a0) ) ? ( (v0) > (v1) ) : ( 0 ) ))
4723 
4724 //static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) U8G_ALWAYS_INLINE;
4725 static uint8_t U8G_ALWAYS_INLINE u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
4726 {
4727  /* surprisingly the macro leads to larger code */
4728  /* return U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1); */
4729  if ( v0 <= a1 )
4730  {
4731  if ( v1 >= a0 )
4732  {
4733  return 1;
4734  }
4735  else
4736  {
4737  if ( v0 > v1 )
4738  {
4739  return 1;
4740  }
4741  else
4742  {
4743  return 0;
4744  }
4745  }
4746  }
4747  else
4748  {
4749  if ( v1 >= a0 )
4750  {
4751  if ( v0 > v1 )
4752  {
4753  return 1;
4754  }
4755  else
4756  {
4757  return 0;
4758  }
4759  }
4760  else
4761  {
4762  return 0;
4763  }
4764  }
4765 }
4766 
4767 
4768 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
4769 {
4770  register u8g_uint_t tmp;
4771  tmp = y;
4772  tmp += h;
4773  tmp--;
4774  if ( u8g_is_intersection_decision_tree(u8g->current_page.y0, u8g->current_page.y1, y, tmp) == 0 )
4775  return 0;
4776 
4777  tmp = x;
4778  tmp += w;
4779  tmp--;
4781 }
4782 
4783 // ============= u8g_com_arduino_std_sw_spi.c =====================
4784 
4785 /*
4786 
4787  u8g_arduino_std_sw_spi.c
4788 
4789  Universal 8bit Graphics Library
4790 
4791  Copyright (c) 2011, olikraus@gmail.com
4792  All rights reserved.
4793 
4794  Redistribution and use in source and binary forms, with or without modification,
4795  are permitted provided that the following conditions are met:
4796 
4797  * Redistributions of source code must retain the above copyright notice, this list
4798  of conditions and the following disclaimer.
4799 
4800  * Redistributions in binary form must reproduce the above copyright notice, this
4801  list of conditions and the following disclaimer in the documentation and/or other
4802  materials provided with the distribution.
4803 
4804  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
4805  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
4806  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4807  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4808  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
4809  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4810  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4811  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4812  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4813  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4814  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4815  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
4816  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4817 
4818 */
4819 
4820 void u8g_arduino_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
4821 {
4822  uint8_t i = 8;
4823  do
4824  {
4825  if ( val & 128 )
4826  digitalWrite(dataPin, HIGH);
4827  else
4828  digitalWrite(dataPin, LOW);
4829  val <<= 1;
4830  u8g_MicroDelay(); /* 23 Sep 2012 */
4831  //delay(1);
4832  digitalWrite(clockPin, HIGH);
4833  u8g_MicroDelay(); /* 23 Sep 2012 */
4834  //delay(1);
4835  digitalWrite(clockPin, LOW);
4836  u8g_MicroDelay(); /* 23 Sep 2012 */
4837  //delay(1);
4838  i--;
4839  } while( i != 0 );
4840 }
4841 
4842 uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
4843 {
4844  switch(msg)
4845  {
4846  case U8G_COM_MSG_INIT:
4850  break;
4851 
4852  case U8G_COM_MSG_STOP:
4853  break;
4854 
4855  case U8G_COM_MSG_RESET:
4856  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
4858  break;
4859 
4861  if ( arg_val == 0 )
4862  {
4863  /* disable */
4865  }
4866  else
4867  {
4868  /* enable */
4871  }
4872  break;
4873 
4875  u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
4876  break;
4877 
4878  case U8G_COM_MSG_WRITE_SEQ:
4879  {
4880  register uint8_t *ptr = (uint8_t*)arg_ptr;
4881  while( arg_val > 0 )
4882  {
4883  u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
4884  arg_val--;
4885  }
4886  }
4887  break;
4888 
4890  {
4891  register uint8_t *ptr = (uint8_t*)arg_ptr;
4892  while( arg_val > 0 )
4893  {
4894  u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
4895  ptr++;
4896  arg_val--;
4897  }
4898  }
4899  break;
4900 
4901  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
4903  break;
4904  }
4905  return 1;
4906 }
4907 
4908 
4909 // ======== u8g_com_atmega_st7920_spi.c ==============
4910 
4911 /*
4912 
4913  u8g_com_atmega_st7920_spi.c
4914 
4915  Universal 8bit Graphics Library
4916 
4917  Copyright (c) 2011, olikraus@gmail.com
4918  All rights reserved.
4919 
4920  Redistribution and use in source and binary forms, with or without modification,
4921  are permitted provided that the following conditions are met:
4922 
4923  * Redistributions of source code must retain the above copyright notice, this list
4924  of conditions and the following disclaimer.
4925 
4926  * Redistributions in binary form must reproduce the above copyright notice, this
4927  list of conditions and the following disclaimer in the documentation and/or other
4928  materials provided with the distribution.
4929 
4930  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
4931  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
4932  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4933  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4934  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
4935  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4936  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4937  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4938  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4939  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4940  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4941  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
4942  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4943 
4944  A special SPI interface for ST7920 controller
4945 
4946 */
4947 
4948 #if defined(__AVR__)
4949 
4950 static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
4951 static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
4952 {
4953  uint8_t i = 8;
4954  do
4955  {
4956  u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
4957  val <<= 1;
4958  u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
4959  u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
4960  u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
4961  u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
4962  i--;
4963  } while( i != 0 );
4964 }
4965 
4966 static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
4967 static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val)
4968 {
4969  uint8_t i;
4970 
4971  if ( rs == 0 )
4972  {
4973  /* command */
4974  u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0f8);
4975  }
4976  else if ( rs == 1 )
4977  {
4978  /* data */
4979  u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0fa);
4980  }
4981 
4982  u8g_atmega_st7920_sw_spi_shift_out(u8g, val & 0x0f0);
4983  u8g_atmega_st7920_sw_spi_shift_out(u8g, val << 4);
4984 
4985  for( i = 0; i < 4; i++ )
4986  u8g_10MicroDelay();
4987 }
4988 
4989 
4990 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
4991 {
4992  switch(msg)
4993  {
4994  case U8G_COM_MSG_INIT:
4997  /* u8g_SetPIOutput(u8g, U8G_PI_A0); */
4998  u8g_SetPIOutput(u8g, U8G_PI_CS);
5000 
5001  u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
5002  u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
5003  u8g_SetPILevel(u8g, U8G_PI_CS, 0 );
5004  /* u8g_SetPILevel(u8g, U8G_PI_A0, 0); */
5005 
5006  u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
5007  break;
5008 
5009  case U8G_COM_MSG_STOP:
5010  break;
5011 
5012  case U8G_COM_MSG_RESET:
5013  u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
5014  break;
5015 
5016  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
5017  u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
5018  break;
5019 
5021  if ( arg_val == 0 )
5022  {
5023  /* disable, note: the st7920 has an active high chip select */
5024  u8g_SetPILevel(u8g, U8G_PI_CS, 0);
5025  }
5026  else
5027  {
5028  /* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
5029  /* enable */
5030  u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
5031  }
5032  break;
5033 
5034 
5036  u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
5037  u8g->pin_list[U8G_PI_A0_STATE] = 2;
5038  break;
5039 
5040  case U8G_COM_MSG_WRITE_SEQ:
5041  {
5042  register uint8_t *ptr = (uint8_t*)arg_ptr;
5043  while( arg_val > 0 )
5044  {
5045  u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
5046  u8g->pin_list[U8G_PI_A0_STATE] = 2;
5047  arg_val--;
5048  }
5049  }
5050  break;
5051 
5053  {
5054  register uint8_t *ptr = (uint8_t*)arg_ptr;
5055  while( arg_val > 0 )
5056  {
5057  u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
5058  u8g->pin_list[U8G_PI_A0_STATE] = 2;
5059  ptr++;
5060  arg_val--;
5061  }
5062  }
5063  break;
5064  }
5065  return 1;
5066 }
5067 
5068 #else
5069 
5070 
5071 uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
5072 {
5073  return 1;
5074 }
5075 
5076 
5077 #endif
5078 
5079 // ================ u8g_butmap.c ===============
5080 
5081 /*
5082 
5083  u8g_bitmap.c
5084 
5085  Universal 8bit Graphics Library
5086 
5087  Copyright (c) 2011, olikraus@gmail.com
5088  All rights reserved.
5089 
5090  Redistribution and use in source and binary forms, with or without modification,
5091  are permitted provided that the following conditions are met:
5092 
5093  * Redistributions of source code must retain the above copyright notice, this list
5094  of conditions and the following disclaimer.
5095 
5096  * Redistributions in binary form must reproduce the above copyright notice, this
5097  list of conditions and the following disclaimer in the documentation and/or other
5098  materials provided with the distribution.
5099 
5100  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
5101  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
5102  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5103  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5104  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
5105  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5106  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5107  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5108  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5109  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
5110  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5111  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5112  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5113 
5114 
5115 */
5116 
5117 
5118 void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
5119 {
5120  while( cnt > 0 )
5121  {
5122  u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
5123  bitmap++;
5124  cnt--;
5125  x+=8;
5126  }
5127 }
5128 
5129 void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
5130 {
5131  if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
5132  return;
5133  while( h > 0 )
5134  {
5135  u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
5136  bitmap += cnt;
5137  y++;
5138  h--;
5139  }
5140 }
5141 
5142 
5143 void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
5144 {
5145  while( cnt > 0 )
5146  {
5147  u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
5148  bitmap++;
5149  cnt--;
5150  x+=8;
5151  }
5152 }
5153 
5154 void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
5155 {
5156  if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
5157  return;
5158  while( h > 0 )
5159  {
5160  u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
5161  bitmap += cnt;
5162  y++;
5163  h--;
5164  }
5165 }
5166 
5167 /*=========================================================================*/
5168 
5169 static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
5170 {
5171  uint8_t d;
5172  x+=7;
5173  while( w >= 8 )
5174  {
5175  u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
5176  bitmap++;
5177  w-= 8;
5178  x+=8;
5179  }
5180  if ( w > 0 )
5181  {
5182  d = *bitmap;
5183  x -= 7;
5184  do
5185  {
5186  if ( d & 1 )
5187  u8g_DrawPixel(u8g, x, y);
5188  x++;
5189  w--;
5190  d >>= 1;
5191  } while ( w > 0 );
5192  }
5193 }
5194 
5195 void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
5196 {
5197  u8g_uint_t b;
5198  b = w;
5199  b += 7;
5200  b >>= 3;
5201 
5202  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
5203  return;
5204 
5205  while( h > 0 )
5206  {
5207  u8g_DrawHXBM(u8g, x, y, w, bitmap);
5208  bitmap += b;
5209  y++;
5210  h--;
5211  }
5212 }
5213 
5214 static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
5215 {
5216  uint8_t d;
5217  x+=7;
5218  while( w >= 8 )
5219  {
5220  u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
5221  bitmap++;
5222  w-= 8;
5223  x+=8;
5224  }
5225  if ( w > 0 )
5226  {
5227  d = u8g_pgm_read(bitmap);
5228  x -= 7;
5229  do
5230  {
5231  if ( d & 1 )
5232  u8g_DrawPixel(u8g, x, y);
5233  x++;
5234  w--;
5235  d >>= 1;
5236  } while ( w > 0 );
5237  }
5238 }
5239 
5240 void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
5241 {
5242  u8g_uint_t b;
5243  b = w;
5244  b += 7;
5245  b >>= 3;
5246 
5247  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
5248  return;
5249  while( h > 0 )
5250  {
5251  u8g_DrawHXBMP(u8g, x, y, w, bitmap);
5252  bitmap += b;
5253  y++;
5254  h--;
5255  }
5256 }
5257 
5258 // ============= u8g_api_ii.c ===============
5259 
5260 /*
5261 
5262  u8g_ll_api.c
5263 
5264  low level api
5265 
5266  Universal 8bit Graphics Library
5267 
5268  Copyright (c) 2011, olikraus@gmail.com
5269  All rights reserved.
5270 
5271  Redistribution and use in source and binary forms, with or without modification,
5272  are permitted provided that the following conditions are met:
5273 
5274  * Redistributions of source code must retain the above copyright notice, this list
5275  of conditions and the following disclaimer.
5276 
5277  * Redistributions in binary form must reproduce the above copyright notice, this
5278  list of conditions and the following disclaimer in the documentation and/or other
5279  materials provided with the distribution.
5280 
5281  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
5282  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
5283  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5284  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5285  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
5286  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5287  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5288  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5289  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5290  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
5291  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5292  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5293  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5294 
5295 
5296 */
5297 
5298 uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
5299 {
5300  return dev->dev_fn(u8g, dev, msg, arg);
5301 }
5302 
5303 /*====================================================================*/
5304 
5305 uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
5306 {
5307  uint8_t r;
5309  r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL);
5312  return r;
5313 }
5314 
5316 {
5319  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL);
5322 }
5323 
5324 uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
5325 {
5326  uint8_t r;
5329  r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL);
5330  if ( r != 0 )
5331  {
5333  }
5335  return r;
5336 }
5337 
5338 uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
5339 {
5340  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast);
5341 }
5342 
5343 void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
5344 {
5345  u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
5346  arg->x = x;
5347  arg->y = y;
5348  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg);
5349 }
5350 
5351 void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
5352 {
5353  u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
5354  arg->x = x;
5355  arg->y = y;
5356  arg->dir = dir;
5357  arg->pixel = pixel;
5358  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg);
5359 }
5360 
5361 void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
5362 {
5363  u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
5364  arg->x = x;
5365  arg->y = y;
5366  arg->dir = dir;
5367  arg->pixel = pixel;
5368  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_4TPIXEL, arg);
5369 }
5370 
5371 
5372 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
5373 uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
5374 {
5375  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg);
5376 }
5377 #endif
5378 
5379 
5380 
5381 u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
5382 {
5383  u8g_uint_t r;
5384  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r);
5385  return r;
5386 }
5387 
5388 u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
5389 {
5390  u8g_uint_t r;
5391  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r);
5392  return r;
5393 }
5394 
5395 u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
5396 {
5397  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL);
5398 }
5399 
5400 
5401 
5402 /*====================================================================*/
5403 
5405 {
5406  u8g->width = u8g_GetWidthLL(u8g, u8g->dev);
5407  u8g->height = u8g_GetHeightLL(u8g, u8g->dev);
5408  u8g->mode = u8g_GetModeLL(u8g, u8g->dev);
5409  /* 9 Dec 2012: u8g_scale.c requires update of current page */
5411 }
5412 
5413 static void u8g_init_data(u8g_t *u8g)
5414 {
5415  u8g->font = NULL;
5416  u8g->cursor_font = NULL;
5417  u8g->cursor_bg_color = 0;
5418  u8g->cursor_fg_color = 1;
5419  u8g->cursor_encoding = 34;
5420  u8g->cursor_fn = (u8g_draw_cursor_fn)0;
5421 
5422 #if defined(U8G_WITH_PINLIST)
5423  {
5424  uint8_t i;
5425  for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
5426  u8g->pin_list[i] = U8G_PIN_NONE;
5427  }
5428 #endif
5429 
5430  u8g_SetColorIndex(u8g, 1);
5431 
5433 
5435  u8g->font_ref_ascent = 0;
5436  u8g->font_ref_descent = 0;
5437  u8g->font_line_spacing_factor = 64; /* 64 = 1.0, 77 = 1.2 line spacing factor */
5438  u8g->line_spacing = 0;
5439 
5441 
5442 }
5443 
5444 uint8_t u8g_Begin(u8g_t *u8g)
5445 {
5446  /* call and init low level driver and com device */
5447  if ( u8g_InitLL(u8g, u8g->dev) == 0 )
5448  return 0;
5449  /* fetch width and height from the low level */
5450  u8g_UpdateDimension(u8g);
5451  return 1;
5452 }
5453 
5454 uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
5455 {
5456  u8g_init_data(u8g);
5457  u8g->dev = dev;
5458 
5459  /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
5460  /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
5461  /* if Arduino call u8g_UpdateDimension else u8g_Begin */
5462  /* issue 146 */
5463  return u8g_Begin(u8g);
5464 }
5465 
5466 /* special init for pure ARM systems */
5467 uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn)
5468 {
5469  u8g_init_data(u8g);
5470 
5471 #if defined(U8G_WITH_PINLIST)
5472  {
5473  uint8_t i;
5474  for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
5475  u8g->pin_list[i] = U8G_PIN_DUMMY;
5476  }
5477 #endif
5478 
5479  u8g->dev = dev;
5480 
5481  /* replace the device procedure with a custom communication procedure */
5482  u8g->dev->com_fn = com_fn;
5483 
5484  /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
5485  /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
5486  /* if Arduino call u8g_UpdateDimension else u8g_Begin */
5487  /* issue 146 */
5488  return u8g_Begin(u8g);
5489 }
5490 
5491 
5492 #if defined(U8G_WITH_PINLIST)
5493 uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
5494 {
5495 
5496  /* fill data structure with some suitable values */
5497  u8g_init_data(u8g);
5498  u8g->dev = dev;
5499 
5500  /* assign user pins */
5501  u8g->pin_list[U8G_PI_SCK] = sck;
5502  u8g->pin_list[U8G_PI_MOSI] = mosi;
5503  u8g->pin_list[U8G_PI_CS] = cs;
5504  u8g->pin_list[U8G_PI_A0] = a0;
5505  u8g->pin_list[U8G_PI_RESET] = reset;
5506 
5507  /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
5508  /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
5509  /* if Arduino call u8g_UpdateDimension else u8g_Begin */
5510  /* issue 146 */
5511  return u8g_Begin(u8g);
5512 }
5513 
5514 uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
5515 {
5516  /* fill data structure with some suitable values */
5517  u8g_init_data(u8g);
5518  u8g->dev = dev;
5519 
5520 
5521  /* assign user pins */
5522  u8g->pin_list[U8G_PI_CS] = cs;
5523  u8g->pin_list[U8G_PI_A0] = a0;
5524  u8g->pin_list[U8G_PI_RESET] = reset;
5525 
5526  return u8g_Begin(u8g);
5527 }
5528 
5529 uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
5530 {
5531  /* fill data structure with some suitable values */
5532  u8g_init_data(u8g);
5533  u8g->dev = dev;
5534 
5535  u8g->pin_list[U8G_PI_I2C_OPTION] = options;
5536 
5537  return u8g_Begin(u8g);
5538 }
5539 
5540 
5541 uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
5542 {
5543 
5544  /* fill data structure with some suitable values */
5545  u8g_init_data(u8g);
5546  u8g->dev = dev;
5547 
5548  /* assign user pins */
5549 
5550  u8g->pin_list[U8G_PI_EN] = en;
5551  u8g->pin_list[U8G_PI_CS] = cs;
5552  u8g->pin_list[U8G_PI_DI] = di;
5553  u8g->pin_list[U8G_PI_RW] = rw;
5554  u8g->pin_list[U8G_PI_RESET] = reset;
5555 
5556  return u8g_Begin(u8g);
5557 }
5558 
5559 uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
5560  uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
5561 {
5562 
5563  /* fill data structure with some suitable values */
5564  u8g_init_data(u8g);
5565  u8g->dev = dev;
5566 
5567  /* assign user pins */
5568 
5569  u8g->pin_list[U8G_PI_D0] = d0;
5570  u8g->pin_list[U8G_PI_D1] = d1;
5571  u8g->pin_list[U8G_PI_D2] = d2;
5572  u8g->pin_list[U8G_PI_D3] = d3;
5573  u8g->pin_list[U8G_PI_D4] = d4;
5574  u8g->pin_list[U8G_PI_D5] = d5;
5575  u8g->pin_list[U8G_PI_D6] = d6;
5576  u8g->pin_list[U8G_PI_D7] = d7;
5577 
5578  u8g->pin_list[U8G_PI_EN] = en;
5579  u8g->pin_list[U8G_PI_CS1] = cs1;
5580  u8g->pin_list[U8G_PI_CS2] = cs2;
5581  u8g->pin_list[U8G_PI_DI] = di;
5582  u8g->pin_list[U8G_PI_RW] = rw;
5583  u8g->pin_list[U8G_PI_RESET] = reset;
5584 
5585  return u8g_Begin(u8g);
5586 }
5587 
5588 /*
5589 
5590  PIN_D0 8
5591  PIN_D1 9
5592  PIN_D2 10
5593  PIN_D3 11
5594  PIN_D4 4
5595  PIN_D5 5
5596  PIN_D6 6
5597  PIN_D7 7
5598 
5599  PIN_CS 14
5600  PIN_A0 15
5601  PIN_RESET 16
5602  PIN_WR 17
5603  PIN_RD 18
5604 
5605  u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
5606  u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16)
5607 
5608 */
5609 
5610 uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
5611  uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
5612 {
5613 
5614  /* fill data structure with some suitable values */
5615  u8g_init_data(u8g);
5616  u8g->dev = dev;
5617 
5618  /* assign user pins */
5619 
5620  u8g->pin_list[U8G_PI_D0] = d0;
5621  u8g->pin_list[U8G_PI_D1] = d1;
5622  u8g->pin_list[U8G_PI_D2] = d2;
5623  u8g->pin_list[U8G_PI_D3] = d3;
5624  u8g->pin_list[U8G_PI_D4] = d4;
5625  u8g->pin_list[U8G_PI_D5] = d5;
5626  u8g->pin_list[U8G_PI_D6] = d6;
5627  u8g->pin_list[U8G_PI_D7] = d7;
5628 
5629  u8g->pin_list[U8G_PI_CS] = cs;
5630  u8g->pin_list[U8G_PI_A0] = a0;
5631  u8g->pin_list[U8G_PI_WR] = wr;
5632  u8g->pin_list[U8G_PI_RD] = rd;
5633  u8g->pin_list[U8G_PI_RESET] = reset;
5634 
5635  return u8g_Begin(u8g);
5636 }
5637 #endif /* defined(U8G_WITH_PINLIST) */
5638 
5640 {
5641  u8g_FirstPageLL(u8g, u8g->dev);
5642 }
5643 
5644 uint8_t u8g_NextPage(u8g_t *u8g)
5645 {
5646  if ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 )
5647  {
5648  u8g->cursor_fn(u8g);
5649  }
5650  return u8g_NextPageLL(u8g, u8g->dev);
5651 }
5652 
5653 uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
5654 {
5655  return u8g_SetContrastLL(u8g, u8g->dev, contrast);
5656 }
5657 
5658 void u8g_SleepOn(u8g_t *u8g)
5659 {
5660  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL);
5661 }
5662 
5664 {
5665  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL);
5666 }
5667 
5668 
5669 void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
5670 {
5671  u8g_DrawPixelLL(u8g, u8g->dev, x, y);
5672 }
5673 
5674 void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
5675 {
5676  u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel);
5677 }
5678 
5679 void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
5680 {
5681  u8g_Draw4TPixelLL(u8g, u8g->dev, x, y, dir, pixel);
5682 }
5683 
5684 
5685 /* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
5686 #ifdef OBSOLETE_CODE
5687 uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
5688 {
5689  /* new code */
5690  u8g_dev_arg_bbx_t arg;
5691  arg.x = x;
5692  arg.y = y;
5693  arg.w = w;
5694  arg.h = h;
5695  return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg);
5696 
5697  /* old code */
5698  //return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
5699 }
5700 #endif
5701 
5702 /*
5703  idx: index for the palette entry (0..255)
5704  r: value for red (0..255)
5705  g: value for green (0..255)
5706  b: value for blue (0..255)
5707 */
5708 void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
5709 {
5710  u8g_dev_arg_irgb_t irgb;
5711  irgb.idx = idx;
5712  irgb.r = r;
5713  irgb.g = g;
5714  irgb.b = b;
5715  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_COLOR_ENTRY, &irgb);
5716 }
5717 
5718 void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
5719 {
5720  u8g->arg_pixel.color = idx;
5721  /*u8g->color_index = idx; */ /* must be removed */
5722 }
5723 
5724 void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb)
5725 {
5726  u8g->arg_pixel.color = rgb&255;
5727  u8g->arg_pixel.hi_color = rgb>>8;
5728  /*u8g->color_index = idx; */ /* must be removed */
5729 }
5730 
5731 void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
5732 {
5733 
5734  r &= ~7;
5735  g >>= 2;
5736  b >>= 3;
5737  u8g->arg_pixel.color = b;
5738  u8g->arg_pixel.color |= (g & 7) << 5;
5739  u8g->arg_pixel.hi_color = r;
5740  u8g->arg_pixel.hi_color |= (g>>3) & 7;
5741 
5742  //u8g_SetHiColor(u8g, U8G_GET_HICOLOR_BY_RGB(r,g,b));
5743 }
5744 
5745 void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
5746 {
5747  if ( u8g->mode == U8G_MODE_R3G3B2 )
5748  {
5749  r &= 0x0e0;
5750  g &= 0x0e0;
5751  g >>= 3;
5752  b >>= 6;
5753  u8g->arg_pixel.color = r | g | b;
5754  }
5755  else if ( u8g->mode == U8G_MODE_HICOLOR )
5756  {
5757  u8g_SetHiColorByRGB(u8g, r,g,b);
5758  }
5759  else
5760  {
5761  u8g->arg_pixel.color = r;
5762  u8g->arg_pixel.hi_color = g;
5763  u8g->arg_pixel.blue = b;
5764  }
5765 }
5766 
5767 
5769 {
5770  return u8g->arg_pixel.color;
5771 }
5772 
5774 {
5775  uint8_t mode;
5776  mode = u8g_GetMode(u8g);
5777  if ( mode == U8G_MODE_R3G3B2 )
5778  return 255; /* white */
5779  else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
5780  return 3; /* max intensity */
5781  else /* if ( u8g.getMode() == U8G_MODE_BW ) */
5782  return 1; /* pixel on */
5783  return 1;
5784 }
5785 
5787 {
5788  if ( u8g->mode == U8G_MODE_HICOLOR )
5789  {
5790  u8g->arg_pixel.color = 0x0ff;
5791  u8g->arg_pixel.hi_color = 0x0ff;
5792  }
5793  else
5794  {
5796  }
5797 }
5798 
5800 {
5801  return 0;
5802 }
5803 
5805 {
5806  u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g)); /* pixel on / black */
5807 }
5808 
5810 {
5811  uint8_t mode;
5812  mode = u8g_GetMode(u8g);
5813  if ( mode == U8G_MODE_R3G3B2 )
5814  return 0x06d; /* gray: 01101101 */
5815  else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
5816  return 1; /* low mid intensity */
5817  else /* if ( u8g.getMode() == U8G_MODE_BW ) */
5818  return 1; /* pixel on */
5819  return 1; /* default */
5820 }
5821 
5823 {
5825 }
5826 
5827 // ============== u8g_com_api.c ==================
5828 /*
5829 
5830  u8g_com_api.c
5831 
5832  Universal 8bit Graphics Library
5833 
5834  Copyright (c) 2011, olikraus@gmail.com
5835  All rights reserved.
5836 
5837  Redistribution and use in source and binary forms, with or without modification,
5838  are permitted provided that the following conditions are met:
5839 
5840  * Redistributions of source code must retain the above copyright notice, this list
5841  of conditions and the following disclaimer.
5842 
5843  * Redistributions in binary form must reproduce the above copyright notice, this
5844  list of conditions and the following disclaimer in the documentation and/or other
5845  materials provided with the distribution.
5846 
5847  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
5848  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
5849  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5850  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5851  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
5852  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5853  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5854  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5855  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5856  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
5857  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5858  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5859  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5860 
5861 
5862 */
5863 
5864 
5865 uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time)
5866 {
5867  return dev->com_fn(u8g, U8G_COM_MSG_INIT, clk_cycle_time, NULL);
5868 }
5869 
5870 void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
5871 {
5872  dev->com_fn(u8g, U8G_COM_MSG_STOP, 0, NULL);
5873 }
5874 
5875 /* cs contains the chip number, which should be enabled */
5876 void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
5877 {
5878  dev->com_fn(u8g, U8G_COM_MSG_CHIP_SELECT, cs, NULL);
5879 }
5880 
5882 {
5883  dev->com_fn(u8g, U8G_COM_MSG_RESET, 0, NULL);
5884 }
5885 
5887 {
5888  dev->com_fn(u8g, U8G_COM_MSG_RESET, 1, NULL);
5889 }
5890 
5891 
5892 void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
5893 {
5894  dev->com_fn(u8g, U8G_COM_MSG_ADDRESS, address, NULL);
5895 }
5896 
5897 uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
5898 {
5899  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, val, NULL);
5900 }
5901 
5902 uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
5903 {
5904  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, cnt, seq);
5905 }
5906 
5907 uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
5908 {
5909  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ_P, cnt, (void *)seq);
5910 }
5911 
5912 /*
5913  sequence := { direct_value | escape_sequence }
5914  direct_value := 0..254
5915  escape_sequence := value_255 | sequence_end | delay | adr | cs | not_used
5916  value_255 := 255 255
5917  sequence_end = 255 254
5918  delay := 255 0..127
5919  adr := 255 0x0e0 .. 0x0ef
5920  cs := 255 0x0d0 .. 0x0df
5921  not_used := 255 101..254
5922 
5923 #define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
5924 #define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
5925 #define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
5926 #define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
5927 #define U8G_ESC_END 255, 254
5928 #define U8G_ESC_255 255, 255
5929 #define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
5930 
5931 */
5932 uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
5933 {
5934  uint8_t is_escape = 0;
5935  uint8_t value;
5936  for(;;)
5937  {
5938  value = u8g_pgm_read(esc_seq);
5939  if ( is_escape == 0 )
5940  {
5941  if ( value != 255 )
5942  {
5943  if ( u8g_WriteByte(u8g, dev, value) == 0 )
5944  return 0;
5945  }
5946  else
5947  {
5948  is_escape = 1;
5949  }
5950  }
5951  else
5952  {
5953  if ( value == 255 )
5954  {
5955  if ( u8g_WriteByte(u8g, dev, value) == 0 )
5956  return 0;
5957  }
5958  else if ( value == 254 )
5959  {
5960  break;
5961  }
5962  else if ( value >= 0x0f0 )
5963  {
5964  /* not yet used, do nothing */
5965  }
5966  else if ( value >= 0xe0 )
5967  {
5968  u8g_SetAddress(u8g, dev, value & 0x0f);
5969  }
5970  else if ( value >= 0xd0 )
5971  {
5972  u8g_SetChipSelect(u8g, dev, value & 0x0f);
5973  }
5974  else if ( value >= 0xc0 )
5975  {
5976  u8g_SetResetLow(u8g, dev);
5977  value &= 0x0f;
5978  value <<= 4;
5979  value+=2;
5980  u8g_Delay(value);
5981  u8g_SetResetHigh(u8g, dev);
5982  u8g_Delay(value);
5983  }
5984  else if ( value >= 0xbe )
5985  {
5986  /* not yet implemented */
5987  /* u8g_SetVCC(u8g, dev, value & 0x01); */
5988  }
5989  else if ( value <= 127 )
5990  {
5991  u8g_Delay(value);
5992  }
5993  is_escape = 0;
5994  }
5995  esc_seq++;
5996  }
5997  return 1;
5998 }
5999 
6000 
6001 // ============ u8g_delay.c ===========
6002 /*
6003 
6004  u8g_delay.c
6005 
6006  Universal 8bit Graphics Library
6007 
6008  Copyright (c) 2011, olikraus@gmail.com
6009  All rights reserved.
6010 
6011  Redistribution and use in source and binary forms, with or without modification,
6012  are permitted provided that the following conditions are met:
6013 
6014  * Redistributions of source code must retain the above copyright notice, this list
6015  of conditions and the following disclaimer.
6016 
6017  * Redistributions in binary form must reproduce the above copyright notice, this
6018  list of conditions and the following disclaimer in the documentation and/or other
6019  materials provided with the distribution.
6020 
6021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
6022  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
6023  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
6024  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6025  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
6026  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6027  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
6028  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6029  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6030  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
6031  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
6033  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6034 
6035 
6036  void u8g_Delay(uint16_t val) Delay by "val" milliseconds
6037  void u8g_MicroDelay(void) Delay be one microsecond
6038  void u8g_10MicroDelay(void) Delay by 10 microseconds
6039 
6040 
6041 */
6042 
6043 
6044 
6045 /*==== Part 1: Derive suitable delay procedure ====*/
6046 
6047 #if defined(ARDUINO)
6048 
6049 # if defined(__AVR__)
6050 # define USE_AVR_DELAY
6051 # elif defined(__PIC32MX)
6052 # define USE_PIC32_DELAY
6053 # elif defined(__arm__) /* Arduino Due */
6054 # define USE_ARDUINO_DELAY
6055 # else
6056 # define USE_ARDUINO_DELAY
6057 # endif
6058 #elif defined(__AVR__)
6059 # define USE_AVR_DELAY
6060 #elif defined(__18CXX)
6061 # define USE_PIC18_DELAY
6062 #elif defined(__arm__)
6063 /* do not define anything, all procedures are expected to be defined outside u8glib */
6064 
6065 /*
6066 void u8g_Delay(uint16_t val);
6067 void u8g_MicroDelay(void);
6068 void u8g_10MicroDelay(void);
6069 */
6070 
6071 #else
6072 # define USE_DUMMY_DELAY
6073 #endif
6074 
6075 
6076 
6077 /*==== Part 2: Definition of the delay procedures ====*/
6078 
6079 /*== AVR Delay ==*/
6080 
6081 #if defined(USE_AVR_DELAY)
6082 #include <avr/interrupt.h>
6083 #include <avr/io.h>
6084 #include <util/delay.h>
6085 
6086 /*
6087  Delay by the provided number of milliseconds.
6088  Thus, a 16 bit value will allow a delay of 0..65 seconds
6089  Makes use of the _delay_loop_2
6090 
6091  _delay_loop_2 will do a delay of n * 4 prozessor cycles.
6092  with f = F_CPU cycles per second,
6093  n = f / (1000 * 4 )
6094  with f = 16000000 the result is 4000
6095  with f = 1000000 the result is 250
6096 
6097  the millisec loop, gcc requires the following overhead:
6098  - movev 1
6099  - subwi 2x2
6100  - bne i 2
6101  ==> 7 cycles
6102  ==> must be devided by 4, rounded up 7/4 = 2
6103 */
6104 void u8g_Delay(uint16_t val)
6105 {
6106  /* old version did a call to the arduino lib: delay(val); */
6107  while( val != 0 )
6108  {
6109  _delay_loop_2( (F_CPU / 4000 ) -2);
6110  val--;
6111  }
6112 }
6113 
6114 /* delay by one micro second */
6115 void u8g_MicroDelay(void)
6116 {
6117 #if (F_CPU / 4000000 ) > 0
6118  _delay_loop_2( (F_CPU / 4000000 ) );
6119 #endif
6120 }
6121 
6122 /* delay by 10 micro seconds */
6123 void u8g_10MicroDelay(void)
6124 {
6125 #if (F_CPU / 400000 ) > 0
6126  _delay_loop_2( (F_CPU / 400000 ) );
6127 #endif
6128 }
6129 
6130 #endif
6131 
6132 
6133 /*== Delay for PIC18 (not tested) ==*/
6134 
6135 #if defined(USE_PIC18_DELAY)
6136 #include <delays.h>
6137 #define GetSystemClock() (64000000ul) // Hz
6138 #define GetInstructionClock() (GetSystemClock()/4)
6139 
6140 void u8g_Delay(uint16_t val)
6141 {/*
6142  unsigned int _iTemp = (val);
6143  while(_iTemp--)
6144  Delay1KTCYx((GetInstructionClock()+999999)/1000000);
6145  */
6146 }
6147 void u8g_MicroDelay(void)
6148 {
6149  /* not implemented */
6150 }
6151 void u8g_10MicroDelay(void)
6152 {
6153  /* not implemented */
6154 }
6155 #endif
6156 
6157 
6158 /*== Arduino Delay ==*/
6159 #if defined(USE_ARDUINO_DELAY)
6160 void u8g_Delay(uint16_t val)
6161 {
6162 #if defined(__arm__)
6163  delayMicroseconds((uint32_t)val*(uint32_t)1000);
6164 #else
6165  delay(val);
6166 #endif
6167 }
6168 void u8g_MicroDelay(void)
6169 {
6170  delayMicroseconds(1);
6171 }
6172 void u8g_10MicroDelay(void)
6173 {
6174  delayMicroseconds(10);
6175 }
6176 #endif
6177 
6178 #if defined(USE_PIC32_DELAY)
6179 /*
6180  Assume chipkit here with F_CPU correctly defined
6181  The problem was, that u8g_Delay() is called within the constructor.
6182  It seems that the chipkit is not fully setup at this time, so a
6183  call to delay() will not work. So here is my own implementation.
6184 
6185 */
6186 #define CPU_COUNTS_PER_SECOND (F_CPU/2UL)
6187 #define TICKS_PER_MILLISECOND (CPU_COUNTS_PER_SECOND/1000UL)
6188 #include "plib.h"
6189 void u8g_Delay(uint16_t val)
6190 {
6191  uint32_t d;
6192  uint32_t s;
6193  d = val;
6194  d *= TICKS_PER_MILLISECOND;
6195  s = ReadCoreTimer();
6196  while ( (uint32_t)(ReadCoreTimer() - s) < d )
6197  ;
6198 }
6199 
6200 void u8g_MicroDelay(void)
6201 {
6202  uint32_t d;
6203  uint32_t s;
6204  d = TICKS_PER_MILLISECOND/1000;
6205  s = ReadCoreTimer();
6206  while ( (uint32_t)(ReadCoreTimer() - s) < d )
6207  ;
6208 }
6209 
6210 void u8g_10MicroDelay(void)
6211 {
6212  uint32_t d;
6213  uint32_t s;
6214  d = TICKS_PER_MILLISECOND/100;
6215  s = ReadCoreTimer();
6216  while ( (uint32_t)(ReadCoreTimer() - s) < d )
6217  ;
6218 }
6219 
6220 #endif
6221 
6222 /*== Any other systems: Dummy Delay ==*/
6223 #if defined(USE_DUMMY_DELAY)
6224 void u8g_Delay(uint16_t val)
6225 {
6226  /* do not know how to delay... */
6227 }
6228 void u8g_MicroDelay(void)
6229 {
6230 }
6232 {
6233 }
6234 #endif
6235 
6236 
6237 // =============== u8g_state.c ================
6238 
6239 /*
6240 
6241  u8g_state.c
6242 
6243  backup and restore hardware state
6244 
6245  Universal 8bit Graphics Library
6246 
6247  Copyright (c) 2011, olikraus@gmail.com
6248  All rights reserved.
6249 
6250  Redistribution and use in source and binary forms, with or without modification,
6251  are permitted provided that the following conditions are met:
6252 
6253  * Redistributions of source code must retain the above copyright notice, this list
6254  of conditions and the following disclaimer.
6255 
6256  * Redistributions in binary form must reproduce the above copyright notice, this
6257  list of conditions and the following disclaimer in the documentation and/or other
6258  materials provided with the distribution.
6259 
6260  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
6261  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
6262  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
6263  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6264  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
6265  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6266  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
6267  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6268  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6269  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
6270  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6271  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
6272  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6273 
6274 
6275  state callback: backup env U8G_STATE_MSG_BACKUP_ENV
6276  device callback: DEV_MSG_INIT
6277  state callback: backup u8g U8G_STATE_MSG_BACKUP_U8G
6278  state callback: restore env U8G_STATE_MSG_RESTORE_ENV
6279 
6280  state callback: backup env U8G_STATE_MSG_BACKUP_ENV
6281  state callback: retore u8g U8G_STATE_MSG_RESTORE_U8G
6282  DEV_MSG_PAGE_FIRST or DEV_MSG_PAGE_NEXT
6283  state callback: restore env U8G_STATE_MSG_RESTORE_ENV
6284 
6285 */
6286 
6287 
6288 void u8g_state_dummy_cb(uint8_t msg)
6289 {
6290  /* the dummy procedure does nothing */
6291 }
6292 
6294 {
6295  u8g->state_cb = backup_cb;
6296  /* in most cases the init message was already sent, so this will backup the */
6297  /* current u8g state */
6298  backup_cb(U8G_STATE_MSG_BACKUP_U8G);
6299 }
6300 
6301 
6302 /*===============================================================*/
6303 /* register variable for restoring interrupt state */
6304 
6305 #if defined(__AVR__)
6306 uint8_t global_SREG_backup;
6307 #endif
6308 
6309 
6310 
6311 /*===============================================================*/
6312 /* AVR */
6313 
6314 #if defined(__AVR__)
6315 #define U8G_ATMEGA_HW_SPI
6316 
6317 /* remove the definition for attiny */
6318 #if __AVR_ARCH__ == 2
6319 #undef U8G_ATMEGA_HW_SPI
6320 #endif
6321 #if __AVR_ARCH__ == 25
6322 #undef U8G_ATMEGA_HW_SPI
6323 #endif
6324 #endif
6325 
6326 #if defined(U8G_ATMEGA_HW_SPI)
6327 #include <avr/interrupt.h>
6328 static uint8_t u8g_state_avr_spi_memory[2];
6329 
6330 void u8g_backup_spi(uint8_t msg)
6331 {
6332  if ( U8G_STATE_MSG_IS_BACKUP(msg) )
6333  {
6334  u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)] = SPCR;
6335  }
6336  else
6337  {
6338  uint8_t tmp = SREG;
6339  cli();
6340  SPCR = 0;
6341  SPCR = u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)];
6342  SREG = tmp;
6343  }
6344 }
6345 
6346 #elif defined(ARDUINO) && defined(__arm__) // Arduino Due, maybe we should better check for __SAM3X8E__
6347 
6348 #include "sam.h"
6349 
6350 struct sam_backup_struct
6351 {
6352  uint32_t mr;
6353  uint32_t sr;
6354  uint32_t csr[4];
6355 } sam_backup[2];
6356 
6357 void u8g_backup_spi(uint8_t msg)
6358 {
6359  uint8_t idx = U8G_STATE_MSG_GET_IDX(msg);
6360  if ( U8G_STATE_MSG_IS_BACKUP(msg) )
6361  {
6362  sam_backup[idx].mr = SPI0->SPI_MR;
6363  sam_backup[idx].sr = SPI0->SPI_SR;
6364  sam_backup[idx].csr[0] = SPI0->SPI_CSR[0];
6365  sam_backup[idx].csr[1] = SPI0->SPI_CSR[1];
6366  sam_backup[idx].csr[2] = SPI0->SPI_CSR[2];
6367  sam_backup[idx].csr[3] = SPI0->SPI_CSR[3];
6368  }
6369  else
6370  {
6371  SPI0->SPI_MR = sam_backup[idx].mr;
6372  SPI0->SPI_CSR[0] = sam_backup[idx].csr[0];
6373  SPI0->SPI_CSR[1] = sam_backup[idx].csr[1];
6374  SPI0->SPI_CSR[2] = sam_backup[idx].csr[2];
6375  SPI0->SPI_CSR[3] = sam_backup[idx].csr[3];
6376  }
6377 }
6378 
6379 #else
6380 
6381 void u8g_backup_spi(uint8_t msg)
6382 {
6383 }
6384 
6385 #endif
6386 
6387 // =========== u8g_pb8h1.c ==============
6388 
6389 /*
6390 
6391  u8g_pb8h1.c
6392 
6393  8bit height monochrom (1 bit) page buffer
6394  byte has horizontal orientation
6395 
6396  Universal 8bit Graphics Library
6397 
6398  Copyright (c) 2011, olikraus@gmail.com
6399  All rights reserved.
6400 
6401  Redistribution and use in source and binary forms, with or without modification,
6402  are permitted provided that the following conditions are met:
6403 
6404  * Redistributions of source code must retain the above copyright notice, this list
6405  of conditions and the following disclaimer.
6406 
6407  * Redistributions in binary form must reproduce the above copyright notice, this
6408  list of conditions and the following disclaimer in the documentation and/or other
6409  materials provided with the distribution.
6410 
6411  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
6412  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
6413  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
6414  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6415  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
6416  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6417  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
6418  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6419  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6420  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
6421  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6422  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
6423  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6424 
6425 
6426  total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
6427 
6428  23. Sep 2012: Bug with down procedure, see FPS 1st page --> fixed (bug located in u8g_clip.c)
6429 
6430 */
6431 
6432 #include <string.h>
6433 
6434 #ifdef __unix__
6435 #include <assert.h>
6436 #endif
6437 
6438 /* NEW_CODE disabled, because the performance increase was too slow and not worth compared */
6439 /* to the increase of code size */
6440 /* #define NEW_CODE */
6441 
6442 #ifdef __unix__
6443 void *u8g_buf_lower_limit;
6444 void *u8g_buf_upper_limit;
6445 #endif
6446 
6447 void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
6448 void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
6449 void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
6451 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
6452 
6453 
6454 #ifdef NEW_CODE
6455 struct u8g_pb_h1_struct
6456 {
6457  u8g_uint_t x;
6458  u8g_uint_t y;
6459  uint8_t *ptr;
6460  uint8_t mask;
6461  uint8_t line_byte_len;
6462  uint8_t cnt;
6463 };
6464 
6465 static uint8_t u8g_pb8h1_bitmask[8] = { 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001 };
6466 
6467 static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s) U8G_NOINLINE;
6468 static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s)
6469 {
6470  register u8g_uint_t x;
6471  x = s->x;
6472  x++;
6473  s->x = x;
6474  x &= 7;
6475  s->mask = u8g_pb8h1_bitmask[x];
6476  if ( x == 0 )
6477  s->ptr++;
6478 }
6479 
6480 static void u8g_pb8h1_state_left(struct u8g_pb_h1_struct *s)
6481 {
6482  register u8g_uint_t x;
6483  x = s->x;
6484  x--;
6485  s->x = x;
6486  x &= 7;
6487  s->mask = u8g_pb8h1_bitmask[x];
6488  if ( x == 7 )
6489  s->ptr--;
6490 }
6491 
6492 static void u8g_pb8h1_state_down(struct u8g_pb_h1_struct *s)
6493 {
6494  s->y++;
6495  s->ptr += s->line_byte_len;
6496 }
6497 
6498 static void u8g_pb8h1_state_up(struct u8g_pb_h1_struct *s)
6499 {
6500  s->y--;
6501  s->ptr -= s->line_byte_len;
6502 }
6503 
6504 static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y) U8G_NOINLINE;
6505 static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y)
6506 {
6507  u8g_uint_t tmp;
6508 
6509  uint8_t *ptr = b->buf;
6510 
6511  s->x = x;
6512  s->y = y;
6513 
6514  y -= b->p.page_y0;
6515 
6516  tmp = b->width;
6517  tmp >>= 3;
6518  s->line_byte_len = tmp;
6519 
6520  /* assume negative y values, can be down to -7, subtract this from the pointer and add correction of 8 to y */
6521  ptr -= tmp*8;
6522  y+=8;
6523  /* it is important that the result of tmp*y can be 16 bit value also for 8 bit mode */
6524  ptr += tmp*y;
6525 
6526  s->mask = u8g_pb8h1_bitmask[x & 7];
6527 
6528  /* assume negative x values (to -7), subtract 8 pixel from the pointer and add 8 to x */
6529  ptr--;
6530  x += 8;
6531  x >>= 3;
6532  ptr += x;
6533  s->ptr = ptr;
6534 }
6535 
6536 static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index) U8G_NOINLINE;
6537 static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index)
6538 {
6539 
6540 #ifdef __unix__
6541  assert( s->ptr >= u8g_buf_lower_limit );
6542  assert( s->ptr < u8g_buf_upper_limit );
6543 #endif
6544 
6545  if ( color_index )
6546  {
6547  *s->ptr |= s->mask;
6548  }
6549  else
6550  {
6551  uint8_t mask = s->mask;
6552  mask ^=0xff;
6553  *s->ptr &= mask;
6554  }
6555 }
6556 #endif
6557 
6558 
6559 void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
6560 {
6561  b->buf = buf;
6562  b->width = width;
6563  u8g_pb_Clear(b);
6564 }
6565 
6566 /* limitation: total buffer must not exceed 256 bytes */
6567 void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
6568 {
6569 #ifdef NEW_CODE
6570  struct u8g_pb_h1_struct s;
6571  u8g_pb8h1_state_init(&s, b, x, y);
6572  u8g_pb8h1_state_set_pixel(&s, color_index);
6573 
6574 // u8g_pb8h1_state_up(&s);
6575 // if ( s.y > b->p.page_y1 )
6576 // return;
6577 // if ( s.x > b->width )
6578 // return;
6579 // u8g_pb8h1_state_set_pixel(&s, color_index);
6580 #else
6581  register uint8_t mask;
6582  u8g_uint_t tmp;
6583  uint8_t *ptr = (uint8_t*)b->buf;
6584 
6585  y -= b->p.page_y0;
6586  tmp = b->width;
6587  tmp >>= 3;
6588  tmp *= (uint8_t)y;
6589  ptr += tmp;
6590 
6591  mask = 0x080;
6592  mask >>= x & 7;
6593  x >>= 3;
6594  ptr += x;
6595  if ( color_index )
6596  {
6597  *ptr |= mask;
6598  }
6599  else
6600  {
6601  mask ^=0xff;
6602  *ptr &= mask;
6603  }
6604 #endif
6605 }
6606 
6607 
6608 void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
6609 {
6610  if ( arg_pixel->y < b->p.page_y0 )
6611  return;
6612  if ( arg_pixel->y > b->p.page_y1 )
6613  return;
6614  if ( arg_pixel->x >= b->width )
6615  return;
6616  u8g_pb8h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
6617 }
6618 
6620 {
6621  register uint8_t pixel = arg_pixel->pixel;
6622  do
6623  {
6624  if ( pixel & 128 )
6625  {
6626  u8g_pb8h1_SetPixel(b, arg_pixel);
6627  }
6628  switch( arg_pixel->dir )
6629  {
6630  case 0: arg_pixel->x++; break;
6631  case 1: arg_pixel->y++; break;
6632  case 2: arg_pixel->x--; break;
6633  case 3: arg_pixel->y--; break;
6634  }
6635  pixel <<= 1;
6636  } while( pixel != 0 );
6637 }
6638 
6640 {
6641  register uint8_t pixel = arg_pixel->pixel;
6642  u8g_uint_t dx = 0;
6643  u8g_uint_t dy = 0;
6644 
6645  switch( arg_pixel->dir )
6646  {
6647  case 0: dx++; break;
6648  case 1: dy++; break;
6649  case 2: dx--; break;
6650  case 3: dy--; break;
6651  }
6652 
6653  do
6654  {
6655  if ( pixel & 128 )
6656  u8g_pb8h1_SetPixel(b, arg_pixel);
6657  arg_pixel->x += dx;
6658  arg_pixel->y += dy;
6659  pixel <<= 1;
6660  } while( pixel != 0 );
6661 }
6662 
6663 #ifdef NEW_CODE
6664 static void u8g_pb8h1_Set8PixelState(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
6665 {
6666  register uint8_t pixel = arg_pixel->pixel;
6667  struct u8g_pb_h1_struct s;
6668  uint8_t cnt;
6669  u8g_pb8h1_state_init(&s, b, arg_pixel->x, arg_pixel->y);
6670  cnt = 8;
6671  switch( arg_pixel->dir )
6672  {
6673  case 0:
6674  do
6675  {
6676  if ( s.x < b->width )
6677  if ( pixel & 128 )
6678  u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
6679  u8g_pb8h1_state_right(&s);
6680  pixel <<= 1;
6681  cnt--;
6682  } while( cnt > 0 && pixel != 0 );
6683  break;
6684  case 1:
6685  do
6686  {
6687  if ( s.y >= b->p.page_y0 )
6688  if ( s.y <= b->p.page_y1 )
6689  if ( pixel & 128 )
6690  u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
6691  u8g_pb8h1_state_down(&s);
6692  pixel <<= 1;
6693  cnt--;
6694  } while( cnt > 0 && pixel != 0 );
6695  break;
6696  case 2:
6697  do
6698  {
6699  if ( s.x < b->width )
6700  if ( pixel & 128 )
6701  u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
6702  u8g_pb8h1_state_left(&s);
6703  pixel <<= 1;
6704  cnt--;
6705  } while( cnt > 0 && pixel != 0 );
6706  break;
6707  case 3:
6708  do
6709  {
6710  if ( s.y >= b->p.page_y0 )
6711  if ( s.y <= b->p.page_y1 )
6712  if ( pixel & 128 )
6713  u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
6714  u8g_pb8h1_state_up(&s);
6715  pixel <<= 1;
6716  cnt--;
6717  } while( cnt > 0 && pixel != 0 );
6718  break;
6719  }
6720 }
6721 #endif
6722 
6723 uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
6724 {
6725  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
6726  switch(msg)
6727  {
6729 #ifdef NEW_CODE
6730  if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
6731  u8g_pb8h1_Set8PixelState(pb, (u8g_dev_arg_pixel_t *)arg);
6732 #else
6733  if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
6735 #endif
6736  break;
6737  case U8G_DEV_MSG_SET_PIXEL:
6739  break;
6740  case U8G_DEV_MSG_INIT:
6741  break;
6742  case U8G_DEV_MSG_STOP:
6743  break;
6745  u8g_pb_Clear(pb);
6746  u8g_page_First(&(pb->p));
6747  break;
6748  case U8G_DEV_MSG_PAGE_NEXT:
6749  if ( u8g_page_Next(&(pb->p)) == 0 )
6750  return 0;
6751  u8g_pb_Clear(pb);
6752  break;
6753 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
6754  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
6755  return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
6756 #endif
6758  u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
6759  break;
6760  case U8G_DEV_MSG_GET_WIDTH:
6761  *((u8g_uint_t *)arg) = pb->width;
6762  break;
6764  *((u8g_uint_t *)arg) = pb->p.total_height;
6765  break;
6767  break;
6768  case U8G_DEV_MSG_SET_XY_CB:
6769  break;
6770  case U8G_DEV_MSG_GET_MODE:
6771  return U8G_MODE_BW;
6772  }
6773  return 1;
6774 }
6775 
6776 // =========== u8g_com_arduino_st7920_spi.c ============
6777 /*
6778 
6779  u8g_com_arduino_st7920_spi.c
6780 
6781  Universal 8bit Graphics Library
6782 
6783  Copyright (c) 2011, olikraus@gmail.com
6784  All rights reserved.
6785 
6786  Redistribution and use in source and binary forms, with or without modification,
6787  are permitted provided that the following conditions are met:
6788 
6789  * Redistributions of source code must retain the above copyright notice, this list
6790  of conditions and the following disclaimer.
6791 
6792  * Redistributions in binary form must reproduce the above copyright notice, this
6793  list of conditions and the following disclaimer in the documentation and/or other
6794  materials provided with the distribution.
6795 
6796  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
6797  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
6798  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
6799  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6800  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
6801  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6802  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
6803  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
6804  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
6805  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
6806  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6807  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
6808  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6809 
6810  A special SPI interface for ST7920 controller
6811 
6812  Update for ATOMIC operation done (01 Jun 2013)
6813  U8G_ATOMIC_OR(ptr, val)
6814  U8G_ATOMIC_AND(ptr, val)
6815  U8G_ATOMIC_START();
6816  U8G_ATOMIC_END();
6817 
6818 
6819 */
6820 
6821 
6822 #if defined(ARDUINO)
6823 
6824 #if defined(__AVR__)
6825 
6826 uint8_t u8g_bitData, u8g_bitNotData;
6827 uint8_t u8g_bitClock, u8g_bitNotClock;
6828 volatile uint8_t *u8g_outData;
6829 volatile uint8_t *u8g_outClock;
6830 
6831 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
6832 {
6833 #ifdef UI_SPI_MOSI
6834  SET_OUTPUT(UI_SPI_MOSI);
6835  SET_OUTPUT(UI_SPI_SCK);
6836  WRITE(UI_SPI_MOSI, LOW);
6837  WRITE(UI_SPI_SCK, HIGH);
6838 #endif
6839 /*
6840  u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
6841  u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
6842  u8g_bitData = digitalPinToBitMask(dataPin);
6843  u8g_bitClock = digitalPinToBitMask(clockPin);
6844 
6845  u8g_bitNotClock = u8g_bitClock;
6846  u8g_bitNotClock ^= 0x0ff;
6847 
6848  u8g_bitNotData = u8g_bitData;
6849  u8g_bitNotData ^= 0x0ff;
6850 */
6851 }
6852 
6853 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
6854 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
6855 {
6856 /*
6857  uint8_t cnt = 8;
6858  uint8_t bitData = u8g_bitData;
6859  uint8_t bitNotData = u8g_bitNotData;
6860  uint8_t bitClock = u8g_bitClock;
6861  uint8_t bitNotClock = u8g_bitNotClock;
6862  volatile uint8_t *outData = u8g_outData;
6863  volatile uint8_t *outClock = u8g_outClock;
6864 
6865 
6866  U8G_ATOMIC_START();
6867  bitData |= *outData;
6868  bitNotData &= *outData;
6869  do
6870  {
6871  if ( val & 128 )
6872  *outData = bitData;
6873  else
6874  *outData = bitNotData;
6875  val <<= 1;
6876  *outClock &= bitNotClock;
6877  cnt--;
6878  // removed micro delays, because AVRs are too slow and the delay is not required
6879  //u8g_MicroDelay();
6880  *outClock |= bitClock;
6881  //u8g_MicroDelay();
6882  } while( cnt != 0 );
6883 
6884 */
6885  U8G_ATOMIC_START();
6886  #ifdef UI_SPI_MOSI
6887 
6888  for(uint8_t cnt=0; cnt<8; cnt++ )
6889  {
6890  WRITE(UI_SPI_SCK, LOW);
6891  WRITE(UI_SPI_MOSI, val&0x80);
6892  val<<=1;
6893  asm volatile("nop\n\t"
6894 "nop\n\t"
6895 "nop\n\t"
6896 "nop\n\t"
6897 ::);
6898  //u8g_MicroDelay();
6899  WRITE(UI_SPI_SCK, HIGH);
6900 asm volatile("nop\n\t"
6901 "nop\n\t"
6902 "nop\n\t"
6903 "nop\n\t"
6904 ::);
6905  //u8g_MicroDelay();
6906  }
6907  #endif
6908  U8G_ATOMIC_END();
6909 }
6910 
6911 #elif defined(__18CXX) || defined(__PIC32MX)
6912 
6913 uint16_t dog_bitData, dog_bitNotData;
6914 uint16_t dog_bitClock, dog_bitNotClock;
6915 volatile uint32_t *dog_outData;
6916 volatile uint32_t *dog_outClock;
6917 volatile uint32_t dog_pic32_spi_tmp;
6918 
6919 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
6920 {
6921  dog_outData = portOutputRegister(digitalPinToPort(dataPin));
6922  dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
6923  dog_bitData = digitalPinToBitMask(dataPin);
6924  dog_bitClock = digitalPinToBitMask(clockPin);
6925 
6926  dog_bitNotClock = dog_bitClock;
6927  dog_bitNotClock ^= 0x0ffff;
6928 
6929  dog_bitNotData = dog_bitData;
6930  dog_bitNotData ^= 0x0ffff;
6931 }
6932 
6933 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
6934 {
6935  uint8_t cnt = 8;
6936  U8G_ATOMIC_START();
6937  do
6938  {
6939  if ( val & 128 )
6940  *dog_outData |= dog_bitData;
6941  else
6942  *dog_outData &= dog_bitNotData;
6943  val <<= 1;
6944  //u8g_MicroDelay();
6945  //*dog_outClock |= dog_bitClock;
6946  *dog_outClock &= dog_bitNotClock;
6947  cnt--;
6948  u8g_MicroDelay();
6949  //*dog_outClock &= dog_bitNotClock;
6950  *dog_outClock |= dog_bitClock;
6951  u8g_MicroDelay();
6952 
6953  } while( cnt != 0 );
6954  U8G_ATOMIC_END();
6955 }
6956 
6957 #else
6958 
6959 /* default interface, Arduino DUE (__arm__) */
6960 
6961 uint8_t u8g_data_pin;
6962 uint8_t u8g_clock_pin;
6963 
6964 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
6965 {
6966  u8g_data_pin = dataPin;
6967  u8g_clock_pin = clockPin;
6968 }
6969 
6970 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
6971 {
6972  uint8_t cnt = 8;
6973  do
6974  {
6975 #ifdef UI_SPI_MOSI
6976  WRITE(UI_SPI_MOSI,val & 128);
6977 #else
6978  if ( val & 128 )
6979  digitalWrite(u8g_data_pin, HIGH);
6980  else
6981  digitalWrite(u8g_data_pin, LOW);
6982 #endif
6983  val <<= 1;
6984  u8g_MicroDelay();
6985 #ifdef UI_SPI_SCK
6986  WRITE(UI_SPI_SCK,LOW);
6987 #else
6988  digitalWrite(u8g_clock_pin, LOW);
6989 #endif
6990  cnt--;
6991  u8g_MicroDelay();
6992 #ifdef UI_SPI_SCK
6993  WRITE(UI_SPI_SCK,HIGH);
6994 #else
6995  digitalWrite(u8g_clock_pin, HIGH);
6996 #endif
6997  u8g_MicroDelay();
6998  } while( cnt != 0 );
6999 }
7000 
7001 #endif
7002 
7003 
7004 static void u8g_com_arduino_st7920_write_byte_seq(uint8_t rs, uint8_t *ptr, uint8_t len)
7005 {
7006  if ( rs == 0 )
7007  {
7008  /* command */
7009  u8g_com_arduino_do_shift_out_msb_first(0x0f8);
7010  }
7011  else if ( rs == 1 )
7012  {
7013  /* data */
7014  u8g_com_arduino_do_shift_out_msb_first(0x0fa);
7015  }
7016 
7017  while( len > 0 )
7018  {
7019  u8g_com_arduino_do_shift_out_msb_first(*ptr & 0x0f0);
7020  u8g_com_arduino_do_shift_out_msb_first(*ptr << 4);
7021  ptr++;
7022  len--;
7023 // u8g_10MicroDelay();
7024  }
7025 
7026 // for( i = 0; i < 4; i++ )
7027  u8g_10MicroDelay();
7028 }
7029 
7030 static void u8g_com_arduino_st7920_write_byte(uint8_t rs, uint8_t val)
7031 {
7032  if ( rs == 0 )
7033  {
7034  /* command */
7035  u8g_com_arduino_do_shift_out_msb_first(0x0f8);
7036  }
7037  else if ( rs == 1 )
7038  {
7039  /* data */
7040  u8g_com_arduino_do_shift_out_msb_first(0x0fa);
7041  }
7042 
7043  u8g_com_arduino_do_shift_out_msb_first(val & 0x0f0);
7044  u8g_com_arduino_do_shift_out_msb_first(val << 4);
7045 
7046 // for( i = 0; i < 4; i++ )
7047  u8g_10MicroDelay();
7048 
7049 }
7050 
7051 
7052 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
7053 {
7054  switch(msg)
7055  {
7056  case U8G_COM_MSG_INIT:
7057  u8g->pin_list[U8G_PI_CS2]=U8G_PIN_NONE;
7059 #ifdef UI_SPI_CS
7060  WRITE(UI_SPI_CS,LOW);
7061 #else
7063 #endif
7064  // u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
7065 #ifdef UI_SPI_SCK
7066  WRITE(UI_SPI_SCK,HIGH);
7067 #else
7069 #endif
7070 #ifdef UI_SPI_MOSI
7071  WRITE(UI_SPI_MOSI,LOW);
7072 #else
7074 #endif
7075  u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
7076  u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
7077  break;
7078 
7079  case U8G_COM_MSG_STOP:
7080  break;
7081 
7082  case U8G_COM_MSG_RESET:
7083  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
7085  break;
7086 
7088 #ifdef UI_SPI_CS
7089  WRITE(UI_SPI_CS,arg_val);
7090 #else
7091  if ( arg_val == 0 )
7092  {
7093  /* disable, note: the st7920 has an active high chip select */
7095  }
7096  else
7097  {
7098  /* enable */
7099  //u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
7101  }
7102 #endif
7103  break;
7104 
7106  u8g_com_arduino_st7920_write_byte( u8g->pin_list[U8G_PI_A0_STATE], arg_val);
7107  //u8g->pin_list[U8G_PI_A0_STATE] = 2;
7108  //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
7109  break;
7110 
7111  case U8G_COM_MSG_WRITE_SEQ:
7112  u8g_com_arduino_st7920_write_byte_seq(u8g->pin_list[U8G_PI_A0_STATE], (uint8_t *)arg_ptr, arg_val);
7113  break;
7114 
7116  {
7117  register uint8_t *ptr = (uint8_t*)arg_ptr;
7118  while( arg_val > 0 )
7119  {
7120  u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
7121  //u8g->pin_list[U8G_PI_A0_STATE] = 2;
7122  ptr++;
7123  arg_val--;
7124  }
7125  }
7126  break;
7127 
7128  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
7129  u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
7130  break;
7131  }
7132  return 1;
7133 }
7134 
7135 #else /* ARDUINO */
7136 
7137 uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
7138 {
7139  return 1;
7140 }
7141 
7142 #endif /* ARDUINO */
7143 
7144 // ============= u8g_com_arduino_common.c =============
7145 /*
7146 
7147  u8g_com_arduino_common.c
7148 
7149  shared procedures for the arduino communication procedures
7150 
7151  Universal 8bit Graphics Library
7152 
7153  Copyright (c) 2011, olikraus@gmail.com
7154  All rights reserved.
7155 
7156  Redistribution and use in source and binary forms, with or without modification,
7157  are permitted provided that the following conditions are met:
7158 
7159  * Redistributions of source code must retain the above copyright notice, this list
7160  of conditions and the following disclaimer.
7161 
7162  * Redistributions in binary form must reproduce the above copyright notice, this
7163  list of conditions and the following disclaimer in the documentation and/or other
7164  materials provided with the distribution.
7165 
7166  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
7167  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
7168  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7169  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7170  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
7171  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7172  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
7173  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7174  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7175  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7176  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7177  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
7178  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7179 
7180 
7181 */
7182 
7183 
7184 #if defined(ARDUINO)
7185 
7186 
7187 void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
7188 {
7189  uint8_t pin;
7190  pin = u8g->pin_list[pin_index];
7191  if ( pin != U8G_PIN_NONE )
7192  digitalWrite(pin, value);
7193 }
7194 
7195 /* this procedure does not set the RW pin */
7197 {
7198  uint8_t i;
7199  /* skip the RW pin, which is the last pin in the list */
7200  for( i = 0; i < U8G_PIN_LIST_LEN-1; i++ )
7201  {
7202  if ( u8g->pin_list[i] != U8G_PIN_NONE )
7203  {
7204  pinMode(u8g->pin_list[i], OUTPUT);
7205  digitalWrite(u8g->pin_list[i], HIGH);
7206  }
7207  }
7208 }
7209 
7210 
7211 #endif
7212 
7213 /*
7214 
7215  u8g_pb.c
7216 
7217  common procedures for the page buffer
7218 
7219  Universal 8bit Graphics Library
7220 
7221  Copyright (c) 2011, olikraus@gmail.com
7222  All rights reserved.
7223 
7224  Redistribution and use in source and binary forms, with or without modification,
7225  are permitted provided that the following conditions are met:
7226 
7227  * Redistributions of source code must retain the above copyright notice, this list
7228  of conditions and the following disclaimer.
7229 
7230  * Redistributions in binary form must reproduce the above copyright notice, this
7231  list of conditions and the following disclaimer in the documentation and/or other
7232  materials provided with the distribution.
7233 
7234  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
7235  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
7236  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7237  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7238  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
7239  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7240  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
7241  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7242  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7243  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7244  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7245  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
7246  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7247 
7248 
7249 */
7250 
7251 
7253 {
7254  uint8_t *ptr = (uint8_t *)b->buf;
7255  uint8_t *end_ptr = ptr;
7256  end_ptr += b->width;
7257  do
7258  {
7259  *ptr++ = 0;
7260  } while( ptr != end_ptr );
7261 }
7262 
7263 /* the following procedure does not work. why? Can be checked with descpic */
7264 /*
7265 void u8g_pb_Clear(u8g_pb_t *b)
7266 {
7267  uint8_t *ptr = (uint8_t *)b->buf;
7268  uint8_t cnt = b->width;
7269  do
7270  {
7271  *ptr++ = 0;
7272  cnt--;
7273  } while( cnt != 0 );
7274 }
7275 */
7276 
7277 /*
7278  intersection assumptions:
7279  a1 <= a2 is always true
7280 */
7281  /*
7282  minimized version
7283  ---1----0 1 b1 <= a2 && b1 > b2
7284  -----1--0 1 b2 >= a1 && b1 > b2
7285  ---1-1--- 1 b1 <= a2 && b2 >= a1
7286  */
7287 /*
7288 uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
7289 {
7290  uint8_t c0, c1, c;
7291  c0 = v0 <= b->p.page_y1;
7292  c1 = v1 >= b->p.page_y0;
7293  c = v0 > v1;
7294  if ( c0 && c1 ) return 1;
7295  if ( c0 && c ) return 1;
7296  if ( c1 && c ) return 1;
7297  return 0;
7298 }
7299 */
7300 
7301 uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
7302 {
7303  uint8_t c1, c2, c3, tmp;
7304  c1 = v0 <= pb->p.page_y1;
7305  c2 = v1 >= pb->p.page_y0;
7306  c3 = v0 > v1;
7307  /*
7308  if ( c1 && c2 )
7309  return 1;
7310  if ( c1 && c3 )
7311  return 1;
7312  if ( c2 && c3 )
7313  return 1;
7314  return 0;
7315  */
7316 
7317  tmp = c1;
7318  c1 &= c2;
7319  c2 &= c3;
7320  c3 &= tmp;
7321  c1 |= c2;
7322  c1 |= c3;
7323  return c1 & 1;
7324 }
7325 
7326 
7327 uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
7328 {
7329  uint8_t /*c0, c1, */ c2, c3;
7330  /*
7331  conditions: b->p.page_y0 < b->p.page_y1
7332  there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
7333  */
7334  /*
7335  c0 = v0 < 0;
7336  c1 = v1 < 0;
7337  */
7338  c2 = v0 > b->width;
7339  c3 = v1 > b->width;
7340  /*if ( c0 && c1 ) return 0;*/
7341  if ( c2 && c3 ) return 0;
7342  /*if ( c1 && c2 ) return 0;*/
7343  return 1;
7344 }
7345 
7347 {
7348  u8g_uint_t tmp;
7349 
7350  tmp = bbx->y;
7351  tmp += bbx->h;
7352  tmp--;
7353 
7354  if ( u8g_pb_IsYIntersection(pb, bbx->y, tmp) == 0 )
7355  return 0;
7356 
7357  /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
7358  tmp = bbx->x;
7359  tmp += bbx->w;
7360  tmp--;
7361 
7362  return u8g_pb_IsXIntersection(pb, bbx->x, tmp);
7363 }
7364 
7365 void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
7366 {
7367  box->x0 = 0;
7368  box->y0 = pb->p.page_y0;
7369  box->x1 = pb->width;
7370  box->x1--;
7371  box->y1 = pb->p.page_y1;
7372 }
7373 
7374 
7376 {
7377  u8g_uint_t v0, v1;
7378  v0 = arg_pixel->y;
7379  v1 = v0;
7380  switch( arg_pixel->dir )
7381  {
7382  case 0:
7383  break;
7384  case 1:
7385  v1 += 8; /* this is independent from the page height */
7386  break;
7387  case 2:
7388  break;
7389  case 3:
7390  v0 -= 8;
7391  break;
7392  }
7393  return u8g_pb_IsYIntersection(b, v0, v1);
7394 }
7395 
7396 
7397 
7399 {
7400  return u8g_WriteSequence(u8g, dev, b->width,(uint8_t*) b->buf);
7401 }
7402 
7403 /*
7404 
7405  u8g_rect.c
7406 
7407  U8G high level interface for horizontal and vertical things
7408 
7409  Universal 8bit Graphics Library
7410 
7411  Copyright (c) 2011, olikraus@gmail.com
7412  All rights reserved.
7413 
7414  Redistribution and use in source and binary forms, with or without modification,
7415  are permitted provided that the following conditions are met:
7416 
7417  * Redistributions of source code must retain the above copyright notice, this list
7418  of conditions and the following disclaimer.
7419 
7420  * Redistributions in binary form must reproduce the above copyright notice, this
7421  list of conditions and the following disclaimer in the documentation and/or other
7422  materials provided with the distribution.
7423 
7424  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
7425  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
7426  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7427  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7428  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
7429  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7430  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
7431  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7432  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7433  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7434  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7435  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
7436  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7437 
7438 
7439 */
7440 
7441 void u8g_draw_hline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
7442 {
7443  uint8_t pixel = 0x0ff;
7444  while( w >= 8 )
7445  {
7446  u8g_Draw8Pixel(u8g, x, y, 0, pixel);
7447  w-=8;
7448  x+=8;
7449  }
7450  if ( w != 0 )
7451  {
7452  w ^=7;
7453  w++;
7454  pixel <<= w&7;
7455  u8g_Draw8Pixel(u8g, x, y, 0, pixel);
7456  }
7457 }
7458 
7459 void u8g_draw_vline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t h)
7460 {
7461  uint8_t pixel = 0x0ff;
7462  while( h >= 8 )
7463  {
7464  u8g_Draw8Pixel(u8g, x, y, 1, pixel);
7465  h-=8;
7466  y+=8;
7467  }
7468  if ( h != 0 )
7469  {
7470  h ^=7;
7471  h++;
7472  pixel <<= h&7;
7473  u8g_Draw8Pixel(u8g, x, y, 1, pixel);
7474  }
7475 }
7476 
7477 void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
7478 {
7479  if ( u8g_IsBBXIntersection(u8g, x, y, w, 1) == 0 )
7480  return;
7481  u8g_draw_hline(u8g, x, y, w);
7482 }
7483 
7484 void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
7485 {
7486  if ( u8g_IsBBXIntersection(u8g, x, y, 1, w) == 0 )
7487  return;
7488  u8g_draw_vline(u8g, x, y, w);
7489 }
7490 
7491 /* restrictions: w > 0 && h > 0 */
7492 void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
7493 {
7494  u8g_uint_t xtmp = x;
7495 
7496  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
7497  return;
7498 
7499 
7500  u8g_draw_hline(u8g, x, y, w);
7501  u8g_draw_vline(u8g, x, y, h);
7502  x+=w;
7503  x--;
7504  u8g_draw_vline(u8g, x, y, h);
7505  y+=h;
7506  y--;
7507  u8g_draw_hline(u8g, xtmp, y, w);
7508 }
7509 
7510 void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
7511 {
7512  do
7513  {
7514  u8g_draw_hline(u8g, x, y, w);
7515  y++;
7516  h--;
7517  } while( h != 0 );
7518 }
7519 
7520 /* restrictions: h > 0 */
7521 void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
7522 {
7523  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
7524  return;
7525  u8g_draw_box(u8g, x, y, w, h);
7526 }
7527 
7528 
7529 void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
7530 {
7531  u8g_uint_t xl, yu;
7532 
7533  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
7534  return;
7535 
7536  xl = x;
7537  xl += r;
7538  yu = y;
7539  yu += r;
7540 
7541  {
7542  u8g_uint_t yl, xr;
7543 
7544  xr = x;
7545  xr += w;
7546  xr -= r;
7547  xr -= 1;
7548 
7549  yl = y;
7550  yl += h;
7551  yl -= r;
7552  yl -= 1;
7553 
7554  u8g_draw_circle(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
7555  u8g_draw_circle(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
7556  u8g_draw_circle(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
7557  u8g_draw_circle(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
7558  }
7559 
7560  {
7561  u8g_uint_t ww, hh;
7562 
7563  ww = w;
7564  ww -= r;
7565  ww -= r;
7566  ww -= 2;
7567  hh = h;
7568  hh -= r;
7569  hh -= r;
7570  hh -= 2;
7571 
7572  xl++;
7573  yu++;
7574  h--;
7575  w--;
7576  u8g_draw_hline(u8g, xl, y, ww);
7577  u8g_draw_hline(u8g, xl, y+h, ww);
7578  u8g_draw_vline(u8g, x, yu, hh);
7579  u8g_draw_vline(u8g, x+w, yu, hh);
7580  }
7581 }
7582 
7583 void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
7584 {
7585  u8g_uint_t xl, yu;
7586  u8g_uint_t yl, xr;
7587 
7588  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
7589  return;
7590 
7591  xl = x;
7592  xl += r;
7593  yu = y;
7594  yu += r;
7595 
7596  xr = x;
7597  xr += w;
7598  xr -= r;
7599  xr -= 1;
7600 
7601  yl = y;
7602  yl += h;
7603  yl -= r;
7604  yl -= 1;
7605 
7606  u8g_draw_disc(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
7607  u8g_draw_disc(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
7608  u8g_draw_disc(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
7609  u8g_draw_disc(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
7610 
7611  {
7612  u8g_uint_t ww, hh;
7613 
7614  ww = w;
7615  ww -= r;
7616  ww -= r;
7617  ww -= 2;
7618  hh = h;
7619  hh -= r;
7620  hh -= r;
7621  hh -= 2;
7622 
7623  xl++;
7624  yu++;
7625  h--;
7626  u8g_draw_box(u8g, xl, y, ww, r+1);
7627  u8g_draw_box(u8g, xl, yl, ww, r+1);
7628  //u8g_draw_hline(u8g, xl, y+h, ww);
7629  u8g_draw_box(u8g, x, yu, w, hh);
7630  //u8g_draw_vline(u8g, x+w, yu, hh);
7631  }
7632 }
7633 
7634 // ============ u8g_com_arduino_ssd_i2c.c =================
7635 
7636 /*
7637 
7638  u8g_com_arduino_ssd_i2c.c
7639 
7640  com interface for arduino (AND atmega) and the SSDxxxx chip (SOLOMON) variant
7641  I2C protocol
7642 
7643  ToDo: Rename this to u8g_com_avr_ssd_i2c.c
7644 
7645  Universal 8bit Graphics Library
7646 
7647  Copyright (c) 2012, olikraus@gmail.com
7648  All rights reserved.
7649 
7650  Redistribution and use in source and binary forms, with or without modification,
7651  are permitted provided that the following conditions are met:
7652 
7653  * Redistributions of source code must retain the above copyright notice, this list
7654  of conditions and the following disclaimer.
7655 
7656  * Redistributions in binary form must reproduce the above copyright notice, this
7657  list of conditions and the following disclaimer in the documentation and/or other
7658  materials provided with the distribution.
7659 
7660  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
7661  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
7662  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7663  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7664  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
7665  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7666  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
7667  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7668  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7669  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7670  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7671  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
7672  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7673 
7674  Special pin usage:
7675  U8G_PI_I2C_OPTION additional options
7676  U8G_PI_A0_STATE used to store the last value of the command/data register selection
7677  U8G_PI_SET_A0 1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
7678  U8G_PI_SCL clock line (NOT USED)
7679  U8G_PI_SDA data line (NOT USED)
7680 
7681  U8G_PI_RESET reset line (currently disabled, see below)
7682 
7683  Protocol:
7684  SLA, Cmd/Data Selection, Arguments
7685  The command/data register is selected by a special instruction byte, which is sent after SLA
7686 
7687  The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
7688 */
7689 
7690 
7691 #if defined(U8G_WITH_PINLIST)
7692 
7693 
7694 #define I2C_SLA (0x3c*2)
7695 //#define I2C_CMD_MODE 0x080
7696 #define I2C_CMD_MODE 0x000
7697 #define I2C_DATA_MODE 0x040
7698 
7699 uint8_t u8g_com_arduino_ssd_start_sequence(u8g_t *u8g)
7700 {
7701  /* are we requested to set the a0 state? */
7702  if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
7703  return 1;
7704 
7705  /* setup bus, might be a repeated start */
7706  if ( u8g_i2c_start(I2C_SLA) == 0 )
7707  return 0;
7708  if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
7709  {
7710  if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
7711  return 0;
7712  }
7713  else
7714  {
7715  if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
7716  return 0;
7717  }
7718 
7719  u8g->pin_list[U8G_PI_SET_A0] = 0;
7720  return 1;
7721 }
7722 
7723 uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
7724 {
7725  switch(msg)
7726  {
7727  case U8G_COM_MSG_INIT:
7728  //u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
7729  //u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
7730  //u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: unknown mode */
7731 
7732  u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
7733 
7734  break;
7735 
7736  case U8G_COM_MSG_STOP:
7737  break;
7738 
7739  case U8G_COM_MSG_RESET:
7740  /* Currently disabled, but it could be enable. Previous restrictions have been removed */
7741  /* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
7742  break;
7743 
7745  u8g->pin_list[U8G_PI_A0_STATE] = 0;
7746  u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
7747  if ( arg_val == 0 )
7748  {
7749  /* disable chip, send stop condition */
7750  u8g_i2c_stop();
7751  }
7752  else
7753  {
7754  /* enable, do nothing: any byte writing will trigger the i2c start */
7755  }
7756  break;
7757 
7759  //u8g->pin_list[U8G_PI_SET_A0] = 1;
7760  if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
7761  return u8g_i2c_stop(), 0;
7762  if ( u8g_i2c_send_byte(arg_val) == 0 )
7763  return u8g_i2c_stop(), 0;
7764  // u8g_i2c_stop();
7765  break;
7766 
7767  case U8G_COM_MSG_WRITE_SEQ:
7768  //u8g->pin_list[U8G_PI_SET_A0] = 1;
7769  if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
7770  return u8g_i2c_stop(), 0;
7771  {
7772  register uint8_t *ptr = (uint8_t*)arg_ptr;
7773  while( arg_val > 0 )
7774  {
7775  if ( u8g_i2c_send_byte(*ptr++) == 0 )
7776  return u8g_i2c_stop(), 0;
7777  arg_val--;
7778  }
7779  }
7780  // u8g_i2c_stop();
7781  break;
7782 
7784  //u8g->pin_list[U8G_PI_SET_A0] = 1;
7785  if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
7786  return u8g_i2c_stop(), 0;
7787  {
7788  register uint8_t *ptr = (uint8_t*)arg_ptr;
7789  while( arg_val > 0 )
7790  {
7791  if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 )
7792  return 0;
7793  ptr++;
7794  arg_val--;
7795  }
7796  }
7797  // u8g_i2c_stop();
7798  break;
7799 
7800  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
7801  u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
7802  u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
7803 
7804 #ifdef OLD_CODE
7805  if ( i2c_state != 0 )
7806  {
7807  u8g_i2c_stop();
7808  i2c_state = 0;
7809  }
7810 
7811  if ( u8g_com_arduino_ssd_start_sequence(arg_val) == 0 )
7812  return 0;
7813 
7814  /* setup bus, might be a repeated start */
7815  /*
7816  if ( u8g_i2c_start(I2C_SLA) == 0 )
7817  return 0;
7818  if ( arg_val == 0 )
7819  {
7820  i2c_state = 1;
7821 
7822  if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
7823  return 0;
7824  }
7825  else
7826  {
7827  i2c_state = 2;
7828  if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
7829  return 0;
7830  }
7831  */
7832 #endif
7833  break;
7834  }
7835  return 1;
7836 }
7837 
7838 #else /* defined(U8G_WITH_PINLIST) */
7839 
7840 uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
7841 {
7842  return 1;
7843 }
7844 
7845 #endif /* defined(U8G_WITH_PINLIST) */
7846 
7847 // ============ u8g_com_i2c.c ===============
7848 
7849 /*
7850 
7851  u8g_com_i2c.c
7852 
7853  generic i2c interface
7854 
7855  Universal 8bit Graphics Library
7856 
7857  Copyright (c) 2011, olikraus@gmail.com
7858  All rights reserved.
7859 
7860  Redistribution and use in source and binary forms, with or without modification,
7861  are permitted provided that the following conditions are met:
7862 
7863  * Redistributions of source code must retain the above copyright notice, this list
7864  of conditions and the following disclaimer.
7865 
7866  * Redistributions in binary form must reproduce the above copyright notice, this
7867  list of conditions and the following disclaimer in the documentation and/or other
7868  materials provided with the distribution.
7869 
7870  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
7871  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
7872  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
7873  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7874  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
7875  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7876  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
7877  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7878  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
7879  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7880  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7881  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
7882  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7883 
7884 */
7885 
7886 
7887 //#define U8G_I2C_WITH_NO_ACK
7888 
7889 static uint8_t u8g_i2c_err_code;
7890 static uint8_t u8g_i2c_opt; /* U8G_I2C_OPT_NO_ACK, SAM: U8G_I2C_OPT_DEV_1 */
7891 /*
7892  position values
7893  1: start condition
7894  2: sla transfer
7895 */
7896 static uint8_t u8g_i2c_err_pos;
7897 
7898 
7900 {
7901  u8g_i2c_err_code = U8G_I2C_ERR_NONE;
7902  u8g_i2c_err_pos = 0;
7903 }
7904 
7905 uint8_t u8g_i2c_get_error(void)
7906 {
7907  return u8g_i2c_err_code;
7908 }
7909 
7910 uint8_t u8g_i2c_get_err_pos(void)
7911 {
7912  return u8g_i2c_err_pos;
7913 }
7914 
7915 static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
7916 {
7917  if ( u8g_i2c_err_code > 0 )
7918  return;
7919  u8g_i2c_err_code |= code;
7920  u8g_i2c_err_pos = pos;
7921 }
7922 
7923 
7924 
7925 #if defined(__AVR__)
7926 #define U8G_ATMEGA_HW_TWI
7927 
7928 /* remove the definition for attiny */
7929 #if __AVR_ARCH__ == 2
7930 #undef U8G_ATMEGA_HW_TWI
7931 #endif
7932 #if __AVR_ARCH__ == 25
7933 #undef U8G_ATMEGA_HW_TWI
7934 #endif
7935 #endif
7936 
7937 #if defined(U8G_ATMEGA_HW_TWI)
7938 
7939 #include <avr/io.h>
7940 #include <util/twi.h>
7941 
7942 
7943 
7944 void u8g_i2c_init(uint8_t options)
7945 {
7946  /*
7947  TWBR: bit rate register
7948  TWSR: status register (contains preselector bits)
7949 
7950  prescalar
7951  0 1
7952  1 4
7953  2 16
7954  3 64
7955 
7956  f = F_CPU/(16+2*TWBR*prescalar)
7957 
7958  F_CPU = 16MHz
7959  TWBR = 152;
7960  TWSR = 0;
7961  --> 50KHz
7962 
7963  TWBR = 72;
7964  TWSR = 0;
7965  --> 100KHz
7966 
7967  TWBR = 12;
7968  TWSR = 0;
7969  --> 400KHz
7970 
7971  F_CPU/(2*100000)-8 --> calculate TWBR value for 100KHz
7972 */
7973  u8g_i2c_opt = options;
7974  TWSR = 0;
7975  if ( options & U8G_I2C_OPT_FAST )
7976  {
7977  TWBR = F_CPU/(2*400000)-8;
7978  }
7979  else
7980  {
7981  TWBR = F_CPU/(2*100000)-8;
7982  }
7984 }
7985 
7986 uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
7987 {
7988  volatile uint16_t cnt = 2000; /* timout value should be > 280 for 50KHz Bus and 16 Mhz CPU, however the start condition might need longer */
7989  while( !(TWCR & mask) )
7990  {
7991  if ( cnt == 0 )
7992  {
7993  if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
7994  {
7995  return 1; /* all ok */
7996  }
7997  else
7998  {
8000  return 0; /* error */
8001  }
8002  }
8003  cnt--;
8004  }
8005  return 1; /* all ok */
8006 }
8007 
8008 /* sla includes all 8 bits (with r/w bit), assums master transmit */
8009 uint8_t u8g_i2c_start(uint8_t sla)
8010 {
8011  register uint8_t status;
8012 
8013  /* send start */
8014  TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
8015 
8016  /* wait */
8017  if ( u8g_i2c_wait(_BV(TWINT), 1) == 0 )
8018  return 0;
8019 
8020  status = TW_STATUS;
8021 
8022  /* check status after start */
8023  if ( status != TW_START && status != TW_REP_START )
8024  {
8026  return 0;
8027  }
8028 
8029  /* set slave address */
8030  TWDR = sla;
8031 
8032  /* enable sla transfer */
8033  TWCR = _BV(TWINT) | _BV(TWEN);
8034 
8035  /* wait */
8036  if ( u8g_i2c_wait(_BV(TWINT), 2) == 0 )
8037  return 0;
8038 
8039  if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
8040  {
8041  /* do not check for ACK */
8042  }
8043  else
8044  {
8045  status = TW_STATUS;
8046  /* check status after sla */
8047  if ( status != TW_MT_SLA_ACK )
8048  {
8050  return 0;
8051  }
8052  }
8053 
8054  return 1;
8055 }
8056 
8057 uint8_t u8g_i2c_send_byte(uint8_t data)
8058 {
8059  register uint8_t status;
8060  TWDR = data;
8061  TWCR = _BV(TWINT) | _BV(TWEN);
8062  if ( u8g_i2c_wait(_BV(TWINT), 3) == 0 )
8063  return 0;
8064 
8065  if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
8066  {
8067  /* do not check for ACK */
8068  }
8069  else
8070  {
8071  status = TW_STATUS;
8072  if ( status != TW_MT_DATA_ACK )
8073  {
8075  return 0;
8076  }
8077  }
8078 
8079  return 1;
8080 }
8081 
8082 void u8g_i2c_stop(void)
8083 {
8084  /* write stop */
8085  TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWSTO);
8086 
8087  /* no error is checked for the stop condition */
8088  u8g_i2c_wait(_BV(TWSTO), 4);
8089 
8090 }
8091 
8092 /*
8093 void twi_send(uint8_t adr, uint8_t data1, uint8_t data2)
8094 {
8095  u8g_i2c_start(adr<<1);
8096  u8g_i2c_send_byte(data1);
8097  u8g_i2c_send_byte(data2);
8098  u8g_i2c_stop();
8099 }
8100 */
8101 
8102 #elif defined(ARDUINO) && defined(__SAM3X8E__)
8103 /* Arduino Due */
8104 #include "Arduino.h"
8105 #include "sam.h"
8106 
8107 /*
8108 
8109 Controller
8110 
8111 TWI0 TWCK0 PA18 A DUE PCB: SCL1
8112 TWI0 TWD0 PA17 A DUE PCB: SDA1
8113 TWI1 TWCK1 PB13 A DUE PCB: SCL 21
8114 TWI1 TWD1 PB12 A DUE PCB: SDA 20
8115 
8116 Arduino definitions
8117 
8118 #define PIN_WIRE_SDA (20u)
8119 #define PIN_WIRE_SCL (21u)
8120 #define WIRE_INTERFACE TWI1
8121 #define WIRE_INTERFACE_ID ID_TWI1
8122 #define WIRE_ISR_HANDLER TWI1_Handler
8123 
8124 #define PIN_WIRE1_SDA (70u)
8125 #define PIN_WIRE1_SCL (71u)
8126 #define WIRE1_INTERFACE TWI0
8127 #define WIRE1_INTERFACE_ID ID_TWI0
8128 #define WIRE1_ISR_HANDLER TWI0_Handler
8129 
8130 
8131 */
8132 
8133 static void i2c_400KHz_delay(void)
8134 {
8135  /* should be at least 4 */
8136  /* should be 5 for 100KHz transfer speed */
8137 
8138 
8139  /*
8140  Arduino Due
8141  0x NOP: 470KHz
8142  4x NOP: 450KHz
8143  8x NOP: 430KHz
8144  16x NOP: 400KHz
8145  */
8146 
8147  __NOP();
8148  __NOP();
8149  __NOP();
8150  __NOP();
8151 
8152  __NOP();
8153  __NOP();
8154  __NOP();
8155  __NOP();
8156 
8157  __NOP();
8158  __NOP();
8159  __NOP();
8160  __NOP();
8161 
8162  __NOP();
8163  __NOP();
8164  __NOP();
8165  __NOP();
8166 }
8167 
8168 static void i2c_100KHz_delay(void)
8169 {
8170  /*
8171  1x u8g_MicroDelay() ca. 130KHz
8172  2x u8g_MicroDelay() ca. 80KHz
8173  */
8174  u8g_MicroDelay();
8175  u8g_MicroDelay();
8176 }
8177 
8178 
8179 uint32_t i2c_started = 0;
8180 uint32_t i2c_scl_pin = 0;
8181 uint32_t i2c_sda_pin = 0;
8182 void (*i2c_delay)(void) = i2c_100KHz_delay;
8183 
8184 const PinDescription *i2c_scl_pin_desc;
8185 const PinDescription *i2c_sda_pin_desc;
8186 
8187 
8188 /* maybe this can be optimized */
8189 static void i2c_init(void)
8190 {
8191  i2c_sda_pin_desc = &(g_APinDescription[i2c_sda_pin]);
8192  i2c_scl_pin_desc = &(g_APinDescription[i2c_scl_pin]);
8193  pinMode(i2c_sda_pin, OUTPUT);
8194  digitalWrite(i2c_sda_pin, HIGH);
8195  pinMode(i2c_scl_pin, OUTPUT);
8196  digitalWrite(i2c_scl_pin, HIGH);
8197  PIO_Configure( i2c_sda_pin_desc->pPort, PIO_OUTPUT_0, i2c_sda_pin_desc->ulPin, PIO_OPENDRAIN );
8198  PIO_Configure( i2c_scl_pin_desc->pPort, PIO_OUTPUT_0, i2c_scl_pin_desc->ulPin, PIO_OPENDRAIN );
8199  PIO_Clear( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin) ;
8200  PIO_Clear( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin) ;
8201  PIO_Configure( i2c_sda_pin_desc->pPort, PIO_INPUT, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
8202  PIO_Configure( i2c_scl_pin_desc->pPort, PIO_INPUT, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
8203  i2c_delay();
8204 }
8205 
8206 /* actually, the scl line is not observed, so this procedure does not return a value */
8207 static void i2c_read_scl_and_delay(void)
8208 {
8209  uint32_t dwMask = i2c_scl_pin_desc->ulPin;
8210  //PIO_Configure( i2c_scl_pin_desc->pPort, PIO_INPUT, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
8211  //PIO_SetInput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
8212 
8213  /* set as input */
8214  i2c_scl_pin_desc->pPort->PIO_ODR = dwMask ;
8215  i2c_scl_pin_desc->pPort->PIO_PER = dwMask ;
8216 
8217  i2c_delay();
8218 }
8219 
8220 static void i2c_clear_scl(void)
8221 {
8222  uint32_t dwMask = i2c_scl_pin_desc->ulPin;
8223 
8224  /* set open collector and drive low */
8225  //PIO_Configure( i2c_scl_pin_desc->pPort, PIO_OUTPUT_0, i2c_scl_pin_desc->ulPin, PIO_OPENDRAIN );
8226  //PIO_SetOutput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, 0, 1, 0);
8227 
8228  /* open drain, zero default output */
8229  i2c_scl_pin_desc->pPort->PIO_MDER = dwMask;
8230  i2c_scl_pin_desc->pPort->PIO_CODR = dwMask;
8231  i2c_scl_pin_desc->pPort->PIO_OER = dwMask;
8232  i2c_scl_pin_desc->pPort->PIO_PER = dwMask;
8233 
8234  //PIO_Clear( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin) ;
8235 }
8236 
8237 static uint8_t i2c_read_sda(void)
8238 {
8239  uint32_t dwMask = i2c_sda_pin_desc->ulPin;
8240  //PIO_Configure( i2c_sda_pin_desc->pPort, PIO_INPUT, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
8241  //PIO_SetInput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
8242 
8243  /* set as input */
8244  i2c_sda_pin_desc->pPort->PIO_ODR = dwMask ;
8245  i2c_sda_pin_desc->pPort->PIO_PER = dwMask ;
8246 
8247 
8248  return 1;
8249 }
8250 
8251 static void i2c_clear_sda(void)
8252 {
8253  uint32_t dwMask = i2c_sda_pin_desc->ulPin;
8254 
8255  /* set open collector and drive low */
8256  //PIO_Configure( i2c_sda_pin_desc->pPort, PIO_OUTPUT_0, i2c_sda_pin_desc->ulPin, PIO_OPENDRAIN );
8257  //PIO_SetOutput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, 0, 1, 0);
8258 
8259  /* open drain, zero default output */
8260  i2c_sda_pin_desc->pPort->PIO_MDER = dwMask ;
8261  i2c_sda_pin_desc->pPort->PIO_CODR = dwMask ;
8262  i2c_sda_pin_desc->pPort->PIO_OER = dwMask ;
8263  i2c_sda_pin_desc->pPort->PIO_PER = dwMask ;
8264 
8265  //PIO_Clear( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin) ;
8266 }
8267 
8268 static void i2c_start(void)
8269 {
8270  if ( i2c_started != 0 )
8271  {
8272  /* if already started: do restart */
8273  i2c_read_sda(); /* SDA = 1 */
8274  i2c_delay();
8275  i2c_read_scl_and_delay();
8276  }
8277  i2c_read_sda();
8278  /*
8279  if (i2c_read_sda() == 0)
8280  {
8281  // do something because arbitration is lost
8282  }
8283  */
8284  /* send the start condition, both lines go from 1 to 0 */
8285  i2c_clear_sda();
8286  i2c_delay();
8287  i2c_clear_scl();
8288  i2c_started = 1;
8289 }
8290 
8291 
8292 static void i2c_stop(void)
8293 {
8294  /* set SDA to 0 */
8295  i2c_clear_sda();
8296  i2c_delay();
8297 
8298  /* now release all lines */
8299  i2c_read_scl_and_delay();
8300 
8301  /* set SDA to 1 */
8302  i2c_read_sda();
8303  i2c_delay();
8304  i2c_started = 0;
8305 }
8306 
8307 static void i2c_write_bit(uint8_t val)
8308 {
8309  if (val)
8310  i2c_read_sda();
8311  else
8312  i2c_clear_sda();
8313 
8314  i2c_delay();
8315  i2c_read_scl_and_delay();
8316  i2c_clear_scl();
8317 }
8318 
8319 static uint8_t i2c_read_bit(void)
8320 {
8321  uint8_t val;
8322  /* do not drive SDA */
8323  i2c_read_sda();
8324  i2c_delay();
8325  i2c_read_scl_and_delay();
8326  val = i2c_read_sda();
8327  i2c_delay();
8328  i2c_clear_scl();
8329  return val;
8330 }
8331 
8332 static uint8_t i2c_write_byte(uint8_t b)
8333 {
8334  i2c_write_bit(b & 128);
8335  i2c_write_bit(b & 64);
8336  i2c_write_bit(b & 32);
8337  i2c_write_bit(b & 16);
8338  i2c_write_bit(b & 8);
8339  i2c_write_bit(b & 4);
8340  i2c_write_bit(b & 2);
8341  i2c_write_bit(b & 1);
8342 
8343  /* read ack from client */
8344  /* 0: ack was given by client */
8345  /* 1: nothing happend during ack cycle */
8346  return i2c_read_bit();
8347 }
8348 
8349 
8350 
8351 void u8g_i2c_init(uint8_t options)
8352 {
8353  u8g_i2c_opt = options;
8355 
8356  if ( u8g_i2c_opt & U8G_I2C_OPT_FAST )
8357  {
8358  i2c_delay = i2c_400KHz_delay;
8359  }
8360  else
8361  {
8362  i2c_delay = i2c_100KHz_delay;
8363  }
8364 
8365 
8366  if ( u8g_i2c_opt & U8G_I2C_OPT_DEV_1 )
8367  {
8368  i2c_scl_pin = PIN_WIRE1_SCL;
8369  i2c_sda_pin = PIN_WIRE1_SDA;
8370 
8371  //REG_PIOA_PDR = PIO_PB12A_TWD1 | PIO_PB13A_TWCK1;
8372  }
8373  else
8374  {
8375 
8376  i2c_scl_pin = PIN_WIRE_SCL;
8377  i2c_sda_pin = PIN_WIRE_SDA;
8378 
8379  //REG_PIOA_PDR = PIO_PA17A_TWD0 | PIO_PA18A_TWCK0;
8380  }
8381 
8382  i2c_init();
8383 
8384 }
8385 
8386 /* sla includes also the r/w bit */
8387 uint8_t u8g_i2c_start(uint8_t sla)
8388 {
8389  i2c_start();
8390  i2c_write_byte(sla);
8391  return 1;
8392 }
8393 
8394 uint8_t u8g_i2c_send_byte(uint8_t data)
8395 {
8396  return i2c_write_byte(data);
8397 }
8398 
8399 void u8g_i2c_stop(void)
8400 {
8401  i2c_stop();
8402 }
8403 
8404 
8405 #elif defined(U8G_RASPBERRY_PI)
8406 
8407 #include <wiringPi.h>
8408 #include <wiringPiI2C.h>
8409 #include <stdio.h>
8410 #include <stdlib.h>
8411 #include <errno.h>
8412 
8413 #define I2C_SLA 0x3c
8414 
8415 static int fd=-1;
8416 static uint8_t i2cMode = 0;
8417 
8418 void u8g_i2c_init(uint8_t options) {
8420  u8g_i2c_opt = options;
8421 
8422  if (wiringPiSetup() == -1) {
8423  printf("wiringPi-Error\n");
8424  exit(1);
8425  }
8426 
8427  fd = wiringPiI2CSetup(I2C_SLA);
8428  if (fd < 0) {
8429  printf ("Unable to open I2C device 0: %s\n", strerror (errno)) ;
8430  exit (1) ;
8431  }
8432  //u8g_SetPIOutput(u8g, U8G_PI_RESET);
8433  //u8g_SetPIOutput(u8g, U8G_PI_A0);
8434 }
8435 uint8_t u8g_i2c_start(uint8_t sla) {
8436  u8g_i2c_send_mode(0);
8437 
8438  return 1;
8439 }
8440 
8441 void u8g_i2c_stop(void) {
8442 }
8443 
8444 uint8_t u8g_i2c_send_mode(uint8_t mode) {
8445  i2cMode = mode;
8446 }
8447 
8448 uint8_t u8g_i2c_send_byte(uint8_t data) {
8449  wiringPiI2CWriteReg8(fd, i2cMode, data);
8450 
8451  return 1;
8452 }
8453 
8454 uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
8455 {
8456  return 1;
8457 }
8458 
8459 #else
8460 
8461 /* empty interface */
8462 
8463 void u8g_i2c_init(uint8_t options)
8464 {
8466 }
8467 
8468 uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
8469 {
8470  return 1;
8471 }
8472 
8473 uint8_t u8g_i2c_start(uint8_t sla)
8474 {
8475  return 1;
8476 }
8477 uint8_t u8g_i2c_send_byte(uint8_t data)
8478 {
8479  return 1;
8480 }
8481 
8482 void u8g_i2c_stop(void)
8483 {
8484 }
8485 
8486 
8487 #endif
8488 // ============== u8g_pb8v1.c ===============
8489 
8490 /*
8491 
8492  u8g_pb8v1.c
8493 
8494  8bit height monochrom (1 bit) page buffer
8495  byte has vertical orientation
8496 
8497  Universal 8bit Graphics Library
8498 
8499  Copyright (c) 2011, olikraus@gmail.com
8500  All rights reserved.
8501 
8502  Redistribution and use in source and binary forms, with or without modification,
8503  are permitted provided that the following conditions are met:
8504 
8505  * Redistributions of source code must retain the above copyright notice, this list
8506  of conditions and the following disclaimer.
8507 
8508  * Redistributions in binary form must reproduce the above copyright notice, this
8509  list of conditions and the following disclaimer in the documentation and/or other
8510  materials provided with the distribution.
8511 
8512  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
8513  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
8514  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
8515  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8516  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
8517  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8518  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
8519  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8520  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
8521  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
8522  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8523  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
8524  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8525 
8526 
8527 */
8528 
8529 void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
8530 void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
8531 void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
8533 
8534 /* Obsolete, usually set by the init of the structure */
8535 void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
8536 {
8537  b->buf = buf;
8538  b->width = width;
8539  u8g_pb_Clear(b);
8540 }
8541 
8542 void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
8543 {
8544  register uint8_t mask;
8545  uint8_t *ptr = (uint8_t*)b->buf;
8546 
8547  y -= b->p.page_y0;
8548  mask = 1;
8549  y &= 0x07;
8550  mask <<= y;
8551  ptr += x;
8552  if ( color_index )
8553  {
8554  *ptr |= mask;
8555  }
8556  else
8557  {
8558  mask ^=0xff;
8559  *ptr &= mask;
8560  }
8561 }
8562 
8563 
8564 void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
8565 {
8566  if ( arg_pixel->y < b->p.page_y0 )
8567  return;
8568  if ( arg_pixel->y > b->p.page_y1 )
8569  return;
8570  if ( arg_pixel->x >= b->width )
8571  return;
8572  u8g_pb8v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
8573 }
8574 
8576 {
8577  register uint8_t pixel = arg_pixel->pixel;
8578  do
8579  {
8580  if ( pixel & 128 )
8581  {
8582  u8g_pb8v1_SetPixel(b, arg_pixel);
8583  }
8584  switch( arg_pixel->dir )
8585  {
8586  case 0: arg_pixel->x++; break;
8587  case 1: arg_pixel->y++; break;
8588  case 2: arg_pixel->x--; break;
8589  case 3: arg_pixel->y--; break;
8590  }
8591  pixel <<= 1;
8592  } while( pixel != 0 );
8593 }
8594 
8595 
8597 {
8598  register uint8_t pixel = arg_pixel->pixel;
8599  u8g_uint_t dx = 0;
8600  u8g_uint_t dy = 0;
8601 
8602  switch( arg_pixel->dir )
8603  {
8604  case 0: dx++; break;
8605  case 1: dy++; break;
8606  case 2: dx--; break;
8607  case 3: dy--; break;
8608  }
8609 
8610  do
8611  {
8612  if ( pixel & 128 )
8613  u8g_pb8v1_SetPixel(b, arg_pixel);
8614  arg_pixel->x += dx;
8615  arg_pixel->y += dy;
8616  pixel <<= 1;
8617  } while( pixel != 0 );
8618 
8619 }
8620 
8621 uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
8622 {
8623  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
8624  switch(msg)
8625  {
8627  if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
8629  break;
8630  case U8G_DEV_MSG_SET_PIXEL:
8632  break;
8633  case U8G_DEV_MSG_INIT:
8634  break;
8635  case U8G_DEV_MSG_STOP:
8636  break;
8638  u8g_pb_Clear(pb);
8639  u8g_page_First(&(pb->p));
8640  break;
8641  case U8G_DEV_MSG_PAGE_NEXT:
8642  if ( u8g_page_Next(&(pb->p)) == 0 )
8643  return 0;
8644  u8g_pb_Clear(pb);
8645  break;
8646 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
8647  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
8648  return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
8649 #endif
8651  u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
8652  break;
8653  case U8G_DEV_MSG_GET_WIDTH:
8654  *((u8g_uint_t *)arg) = pb->width;
8655  break;
8657  *((u8g_uint_t *)arg) = pb->p.total_height;
8658  break;
8660  break;
8661  case U8G_DEV_MSG_SET_XY_CB:
8662  break;
8663  case U8G_DEV_MSG_GET_MODE:
8664  return U8G_MODE_BW;
8665  }
8666  return 1;
8667 }
8668 
8669 
8670 // ============== u8g_pb16v1.c ================
8671 
8672 /*
8673 
8674  u8g_pb16v1.c
8675 
8676  16bit height monochrom (1 bit) page buffer
8677  byte has vertical orientation
8678 
8679  Universal 8bit Graphics Library
8680 
8681  Copyright (c) 2011, olikraus@gmail.com
8682  All rights reserved.
8683 
8684  Redistribution and use in source and binary forms, with or without modification,
8685  are permitted provided that the following conditions are met:
8686 
8687  * Redistributions of source code must retain the above copyright notice, this list
8688  of conditions and the following disclaimer.
8689 
8690  * Redistributions in binary form must reproduce the above copyright notice, this
8691  list of conditions and the following disclaimer in the documentation and/or other
8692  materials provided with the distribution.
8693 
8694  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
8695  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
8696  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
8697  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8698  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
8699  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8700  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
8701  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8702  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
8703  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
8704  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8705  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
8706  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8707 
8708 
8709 */
8710 
8711 #include <string.h>
8712 
8713 void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
8714 void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
8715 void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
8717 
8718 
8720 {
8721  uint8_t *ptr = (uint8_t *)b->buf;
8722  uint8_t *end_ptr = ptr;
8723  end_ptr += b->width*2;
8724  do
8725  {
8726  *ptr++ = 0;
8727  } while( ptr != end_ptr );
8728 }
8729 
8730 /* Obsolete, usually set by the init of the structure */
8731 void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
8732 {
8733  b->buf = buf;
8734  b->width = width;
8735  u8g_pb16v1_Clear(b);
8736 }
8737 
8738 void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
8739 {
8740  register uint8_t mask;
8741  uint8_t *ptr = (uint8_t*)b->buf;
8742 
8743  y -= b->p.page_y0;
8744  if ( y >= 8 )
8745  {
8746  ptr += b->width;
8747  y &= 0x07;
8748  }
8749  mask = 1;
8750  mask <<= y;
8751  ptr += x;
8752  if ( color_index )
8753  {
8754  *ptr |= mask;
8755  }
8756  else
8757  {
8758  mask ^=0xff;
8759  *ptr &= mask;
8760  }
8761 }
8762 
8763 
8764 void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
8765 {
8766  if ( arg_pixel->y < b->p.page_y0 )
8767  return;
8768  if ( arg_pixel->y > b->p.page_y1 )
8769  return;
8770  if ( arg_pixel->x >= b->width )
8771  return;
8772  u8g_pb16v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
8773 }
8774 
8776 {
8777  register uint8_t pixel = arg_pixel->pixel;
8778  do
8779  {
8780  if ( pixel & 128 )
8781  {
8782  u8g_pb16v1_SetPixel(b, arg_pixel);
8783  }
8784  switch( arg_pixel->dir )
8785  {
8786  case 0: arg_pixel->x++; break;
8787  case 1: arg_pixel->y++; break;
8788  case 2: arg_pixel->x--; break;
8789  case 3: arg_pixel->y--; break;
8790  }
8791  pixel <<= 1;
8792  } while( pixel != 0 );
8793 }
8794 
8795 
8797 {
8798  register uint8_t pixel = arg_pixel->pixel;
8799  u8g_uint_t dx = 0;
8800  u8g_uint_t dy = 0;
8801 
8802  switch( arg_pixel->dir )
8803  {
8804  case 0: dx++; break;
8805  case 1: dy++; break;
8806  case 2: dx--; break;
8807  case 3: dy--; break;
8808  }
8809 
8810  do
8811  {
8812  if ( pixel & 128 )
8813  u8g_pb16v1_SetPixel(b, arg_pixel);
8814  arg_pixel->x += dx;
8815  arg_pixel->y += dy;
8816  pixel <<= 1;
8817  } while( pixel != 0 );
8818 
8819 }
8820 
8821 uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
8822 {
8823  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
8824  switch(msg)
8825  {
8827  if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
8829  break;
8830  case U8G_DEV_MSG_SET_PIXEL:
8832  break;
8833  case U8G_DEV_MSG_INIT:
8834  break;
8835  case U8G_DEV_MSG_STOP:
8836  break;
8838  u8g_pb16v1_Clear(pb);
8839  u8g_page_First(&(pb->p));
8840  break;
8841  case U8G_DEV_MSG_PAGE_NEXT:
8842  if ( u8g_page_Next(&(pb->p)) == 0 )
8843  return 0;
8844  u8g_pb16v1_Clear(pb);
8845  break;
8846 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
8847  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
8848  return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
8849 #endif
8851  u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
8852  break;
8853  case U8G_DEV_MSG_GET_WIDTH:
8854  *((u8g_uint_t *)arg) = pb->width;
8855  break;
8857  *((u8g_uint_t *)arg) = pb->p.total_height;
8858  break;
8860  break;
8861  case U8G_DEV_MSG_SET_XY_CB:
8862  break;
8863  case U8G_DEV_MSG_GET_MODE:
8864  return U8G_MODE_BW;
8865  }
8866  return 1;
8867 }
8868 
8869 // ========== u8g_arduino_sw_spi.c ================
8870 
8871 /*
8872 
8873  u8g_arduino_sw_spi.c
8874 
8875  Universal 8bit Graphics Library
8876 
8877  Copyright (c) 2011, olikraus@gmail.com
8878  All rights reserved.
8879 
8880  Redistribution and use in source and binary forms, with or without modification,
8881  are permitted provided that the following conditions are met:
8882 
8883  * Redistributions of source code must retain the above copyright notice, this list
8884  of conditions and the following disclaimer.
8885 
8886  * Redistributions in binary form must reproduce the above copyright notice, this
8887  list of conditions and the following disclaimer in the documentation and/or other
8888  materials provided with the distribution.
8889 
8890  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
8891  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
8892  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
8893  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
8894  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
8895  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8896  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
8897  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
8898  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
8899  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
8900  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8901  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
8902  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8903 
8904  Update for ATOMIC operation done (01 Jun 2013)
8905  U8G_ATOMIC_OR(ptr, val)
8906  U8G_ATOMIC_AND(ptr, val)
8907  U8G_ATOMIC_START();
8908  U8G_ATOMIC_END();
8909 
8910 
8911 */
8912 
8913 #if defined(ARDUINO)
8914 
8915 /*=========================================================*/
8916 /* Arduino, AVR */
8917 
8918 #if defined(__AVR__)
8919 
8920 //uint8_t u8g_bitData, u8g_bitNotData;
8921 //uint8_t u8g_bitClock, u8g_bitNotClock;
8922 //volatile uint8_t *u8g_outData;
8923 //volatile uint8_t *u8g_outClock;
8924 
8925 /*static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
8926 {
8927  u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
8928  u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
8929  u8g_bitData = digitalPinToBitMask(dataPin);
8930  u8g_bitClock = digitalPinToBitMask(clockPin);
8931 
8932  u8g_bitNotClock = u8g_bitClock;
8933  u8g_bitNotClock ^= 0x0ff;
8934 
8935  u8g_bitNotData = u8g_bitData;
8936  u8g_bitNotData ^= 0x0ff;
8937 }
8938 
8939 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
8940 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
8941 {
8942  uint8_t cnt = 8;
8943  uint8_t bitData = u8g_bitData;
8944  uint8_t bitNotData = u8g_bitNotData;
8945  uint8_t bitClock = u8g_bitClock;
8946  uint8_t bitNotClock = u8g_bitNotClock;
8947  volatile uint8_t *outData = u8g_outData;
8948  volatile uint8_t *outClock = u8g_outClock;
8949  U8G_ATOMIC_START();
8950  do
8951  {
8952  if ( val & 128 )
8953  *outData |= bitData;
8954  else
8955  *outData &= bitNotData;
8956 
8957  *outClock |= bitClock;
8958  val <<= 1;
8959  cnt--;
8960  *outClock &= bitNotClock;
8961  } while( cnt != 0 );
8962  U8G_ATOMIC_END();
8963 }*/
8964 
8965 /*=========================================================*/
8966 /* Arduino, Chipkit */
8967 #elif defined(__18CXX) || defined(__PIC32MX)
8968 
8969 uint16_t dog_bitData, dog_bitNotData;
8970 uint16_t dog_bitClock, dog_bitNotClock;
8971 volatile uint32_t *dog_outData;
8972 volatile uint32_t *dog_outClock;
8973 volatile uint32_t dog_pic32_spi_tmp;
8974 
8975 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
8976 {
8977  dog_outData = portOutputRegister(digitalPinToPort(dataPin));
8978  dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
8979  dog_bitData = digitalPinToBitMask(dataPin);
8980  dog_bitClock = digitalPinToBitMask(clockPin);
8981 
8982  dog_bitNotClock = dog_bitClock;
8983  dog_bitNotClock ^= 0x0ffff;
8984 
8985  dog_bitNotData = dog_bitData;
8986  dog_bitNotData ^= 0x0ffff;
8987 }
8988 
8989 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
8990 {
8991  uint8_t cnt = 8;
8992  U8G_ATOMIC_START();
8993  do
8994  {
8995  if ( val & 128 )
8996  *dog_outData |= dog_bitData;
8997  else
8998  *dog_outData &= dog_bitNotData;
8999  val <<= 1;
9000  /*
9001  There must be some delay here. However
9002  fetching the adress dog_outClock is enough delay, so
9003  do not place dog_outClock in a local variable. This will
9004  break the procedure
9005  */
9006  *dog_outClock |= dog_bitClock;
9007  cnt--;
9008  *dog_outClock &= dog_bitNotClock;
9009  /*
9010  little additional delay after clk pulse, done by 3x32bit reads
9011  from I/O. Optimized for PIC32 with 80 MHz.
9012  */
9013  dog_pic32_spi_tmp = *dog_outClock;
9014  dog_pic32_spi_tmp = *dog_outClock;
9015  dog_pic32_spi_tmp = *dog_outClock;
9016  } while( cnt != 0 );
9017  U8G_ATOMIC_END();
9018 }
9019 
9020 /*=========================================================*/
9021 /* Arduino Due */
9022 #elif defined(__SAM3X8E__)
9023 
9024 /* Due */
9025 
9026 void u8g_digital_write_sam_high(uint8_t pin)
9027 {
9028  PIO_Set( g_APinDescription[pin].pPort, g_APinDescription[pin].ulPin) ;
9029 }
9030 
9031 void u8g_digital_write_sam_low(uint8_t pin)
9032 {
9033  PIO_Clear( g_APinDescription[pin].pPort, g_APinDescription[pin].ulPin) ;
9034 }
9035 
9036 static uint8_t u8g_sam_data_pin;
9037 static uint8_t u8g_sam_clock_pin;
9038 
9039 /*static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
9040 {
9041  u8g_sam_data_pin = dataPin;
9042  u8g_sam_clock_pin = clockPin;
9043 }
9044 
9045 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
9046 {
9047  uint8_t i = 8;
9048  do
9049  {
9050  if ( val & 128 )
9051  u8g_digital_write_sam_high(u8g_sam_data_pin);
9052  else
9053  u8g_digital_write_sam_low(u8g_sam_data_pin);
9054  val <<= 1;
9055  //u8g_MicroDelay();
9056  u8g_digital_write_sam_high(u8g_sam_clock_pin);
9057  u8g_MicroDelay();
9058  u8g_digital_write_sam_low(u8g_sam_clock_pin);
9059  u8g_MicroDelay();
9060  i--;
9061  } while( i != 0 );
9062 }
9063 */
9064 
9065 #else
9066 /* empty interface */
9067 
9068 static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
9069 {
9070 }
9071 
9072 static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
9073 {
9074 }
9075 
9076 #endif
9077 
9078 
9079 uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9080 {
9081  switch(msg)
9082  {
9083  case U8G_COM_MSG_INIT:
9087  u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
9088  break;
9089 
9090  case U8G_COM_MSG_STOP:
9091  break;
9092 
9093  case U8G_COM_MSG_RESET:
9094  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
9096  break;
9097 
9099  if ( arg_val == 0 )
9100  {
9101  /* disable */
9103  }
9104  else
9105  {
9106  /* enable */
9109  /* issue 227 */
9110  u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
9111  }
9112  break;
9113 
9115  u8g_com_arduino_do_shift_out_msb_first( arg_val );
9116  //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
9117  break;
9118 
9119  case U8G_COM_MSG_WRITE_SEQ:
9120  {
9121  register uint8_t *ptr = (uint8_t*)arg_ptr;
9122  while( arg_val > 0 )
9123  {
9124  u8g_com_arduino_do_shift_out_msb_first(*ptr++);
9125  // u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
9126  arg_val--;
9127  }
9128  }
9129  break;
9130 
9132  {
9133  register uint8_t *ptr = (uint8_t*)arg_ptr;
9134  while( arg_val > 0 )
9135  {
9136  u8g_com_arduino_do_shift_out_msb_first( u8g_pgm_read(ptr) );
9137  //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
9138  ptr++;
9139  arg_val--;
9140  }
9141  }
9142  break;
9143 
9144  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
9146  break;
9147  }
9148  return 1;
9149 }
9150 
9151 #else /* ARDUINO */
9152 
9153 uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9154 {
9155  return 1;
9156 }
9157 
9158 #endif /* ARDUINO */
9159 
9160 // ================ u8g_dev_ks0108_128x64.c ===================
9161 
9162 /*
9163 
9164  u8g_dev_ks0108_128x64.c
9165 
9166  Universal 8bit Graphics Library
9167 
9168  Copyright (c) 2011, olikraus@gmail.com
9169  All rights reserved.
9170 
9171  Redistribution and use in source and binary forms, with or without modification,
9172  are permitted provided that the following conditions are met:
9173 
9174  * Redistributions of source code must retain the above copyright notice, this list
9175  of conditions and the following disclaimer.
9176 
9177  * Redistributions in binary form must reproduce the above copyright notice, this
9178  list of conditions and the following disclaimer in the documentation and/or other
9179  materials provided with the distribution.
9180 
9181  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
9182  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
9183  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9184  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9185  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
9186  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9187  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9188  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9189  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
9190  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9191  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9192  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9193  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9194 
9195 
9196  ADDRESS = 0 (Command Mode)
9197  0x03f Display On
9198  0x0c0 Start Display at line 0
9199  0x040 | y write to y address (y:0..63)
9200  0x0b8 | x write to page [0..7]
9201 
9202 
9203  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
9204  u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
9205 
9206 */
9207 
9208 #define WIDTH 128
9209 #define HEIGHT 64
9210 #define PAGE_HEIGHT 8
9211 
9212 static const uint8_t u8g_dev_ks0108_128x64_init_seq[] PROGMEM = {
9213  U8G_ESC_CS(0), /* disable chip */
9214  U8G_ESC_ADR(0), /* instruction mode */
9215  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
9216  U8G_ESC_CS(1), /* enable chip 1 */
9217  0x03f, /* display on */
9218  0x0c0, /* start at line 0 */
9219  U8G_ESC_DLY(20), /* delay 20 ms */
9220  U8G_ESC_CS(2), /* enable chip 2 */
9221  0x03f, /* display on */
9222  0x0c0, /* start at line 0 */
9223  U8G_ESC_DLY(20), /* delay 20 ms */
9224  U8G_ESC_CS(0), /* disable all chips */
9225  U8G_ESC_END /* end of sequence */
9226 };
9227 
9228 
9229 uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
9230 {
9231 
9232  switch(msg)
9233  {
9234  case U8G_DEV_MSG_INIT:
9236  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ks0108_128x64_init_seq);
9237  break;
9238  case U8G_DEV_MSG_STOP:
9239  break;
9240  case U8G_DEV_MSG_PAGE_NEXT:
9241  {
9242  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
9243 
9244  u8g_SetAddress(u8g, dev, 0); /* command mode */
9245  u8g_SetChipSelect(u8g, dev, 2);
9246  u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
9247  u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
9248  u8g_SetAddress(u8g, dev, 1); /* data mode */
9249  u8g_WriteSequence(u8g, dev, 64, (uint8_t*)pb->buf);
9250  u8g_SetChipSelect(u8g, dev, 0);
9251 
9252  u8g_SetAddress(u8g, dev, 0); /* command mode */
9253  u8g_SetChipSelect(u8g, dev, 1);
9254  u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
9255  u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
9256  u8g_SetAddress(u8g, dev, 1); /* data mode */
9257  u8g_WriteSequence(u8g, dev, 64, 64+(uint8_t *)pb->buf);
9258  u8g_SetChipSelect(u8g, dev, 0);
9259 
9260  }
9261  break;
9262  }
9263  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
9264 }
9265 
9267 U8G_PB_DEV(u8g_dev_ks0108_128x64_fast, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_FAST_PARALLEL);
9268 
9269 // ================= 8g_com_arduino_parallel.c ==================
9270 
9271 /*
9272 
9273  u8g_com_arduino_parallel.c
9274 
9275  Universal 8bit Graphics Library
9276 
9277  Copyright (c) 2011, olikraus@gmail.com
9278  All rights reserved.
9279 
9280  Redistribution and use in source and binary forms, with or without modification,
9281  are permitted provided that the following conditions are met:
9282 
9283  * Redistributions of source code must retain the above copyright notice, this list
9284  of conditions and the following disclaimer.
9285 
9286  * Redistributions in binary form must reproduce the above copyright notice, this
9287  list of conditions and the following disclaimer in the documentation and/or other
9288  materials provided with the distribution.
9289 
9290  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
9291  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
9292  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9293  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9294  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
9295  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9296  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9297  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9298  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
9299  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9300  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9301  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9302  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9303 
9304 
9305  PIN_D0 8
9306  PIN_D1 9
9307  PIN_D2 10
9308  PIN_D3 11
9309  PIN_D4 4
9310  PIN_D5 5
9311  PIN_D6 6
9312  PIN_D7 7
9313 
9314  PIN_CS1 14
9315  PIN_CS2 15
9316  PIN_RW 16
9317  PIN_DI 17
9318  PIN_EN 18
9319 
9320  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
9321  u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
9322 
9323 */
9324 
9325 #if defined(ARDUINO)
9326 
9327 
9328 void u8g_com_arduino_parallel_write(u8g_t *u8g, uint8_t val)
9329 {
9331  val >>= 1;
9333  val >>= 1;
9335  val >>= 1;
9337  val >>= 1;
9339  val >>= 1;
9341  val >>= 1;
9343  val >>= 1;
9345 
9346  /* EN cycle time must be 1 micro second, digitalWrite is slow enough to do this */
9348  u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
9350  u8g_10MicroDelay(); /* ST7920 commands: 72us */
9351 }
9352 
9353 
9354 uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9355 {
9356  switch(msg)
9357  {
9358  case U8G_COM_MSG_INIT:
9359  /* setup the RW pin as output and force it to low */
9360  if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
9361  {
9362  pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
9364  }
9365  /* set all pins (except RW pin) */
9367  break;
9368  case U8G_COM_MSG_STOP:
9369  break;
9371  if ( arg_val == 0 )
9372  {
9373  /* disable */
9376  }
9377  else if ( arg_val == 1 )
9378  {
9379  /* enable */
9382  }
9383  else if ( arg_val == 2 )
9384  {
9385  /* enable */
9388  }
9389  else
9390  {
9391  /* enable */
9394  }
9395  break;
9397  u8g_com_arduino_parallel_write(u8g, arg_val);
9398  break;
9399  case U8G_COM_MSG_WRITE_SEQ:
9400  {
9401  register uint8_t *ptr = (uint8_t*)arg_ptr;
9402  while( arg_val > 0 )
9403  {
9404  u8g_com_arduino_parallel_write(u8g, *ptr++);
9405  arg_val--;
9406  }
9407  }
9408  break;
9410  {
9411  register uint8_t *ptr = (uint8_t*)arg_ptr;
9412  while( arg_val > 0 )
9413  {
9414  u8g_com_arduino_parallel_write(u8g, u8g_pgm_read(ptr));
9415  ptr++;
9416  arg_val--;
9417  }
9418  }
9419  break;
9420  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
9422  break;
9423  case U8G_COM_MSG_RESET:
9424  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
9426  break;
9427 
9428  }
9429  return 1;
9430 }
9431 
9432 #else
9433 
9434 
9435 uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9436 {
9437  return 1;
9438 }
9439 
9440 #endif /* ARDUINO */
9441 
9442 
9443 // =============== u8g_arduino_fast_parallel.c ================
9444 /*
9445 
9446  u8g_arduino_fast_parallel.c
9447 
9448  Universal 8bit Graphics Library
9449 
9450  Copyright (c) 2011, olikraus@gmail.com
9451  All rights reserved.
9452 
9453  Redistribution and use in source and binary forms, with or without modification,
9454  are permitted provided that the following conditions are met:
9455 
9456  * Redistributions of source code must retain the above copyright notice, this list
9457  of conditions and the following disclaimer.
9458 
9459  * Redistributions in binary form must reproduce the above copyright notice, this
9460  list of conditions and the following disclaimer in the documentation and/or other
9461  materials provided with the distribution.
9462 
9463  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
9464  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
9465  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9466  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9467  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
9468  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9469  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9470  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9471  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
9472  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9473  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9474  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9475  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9476 
9477  PIN_D0 8
9478  PIN_D1 9
9479  PIN_D2 10
9480  PIN_D3 11
9481  PIN_D4 4
9482  PIN_D5 5
9483  PIN_D6 6
9484  PIN_D7 7
9485 
9486  PIN_CS1 14
9487  PIN_CS2 15
9488  PIN_RW 16
9489  PIN_DI 17
9490  PIN_EN 18
9491 
9492  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
9493  u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
9494 
9495  Update for ATOMIC operation done (01 Jun 2013)
9496  U8G_ATOMIC_OR(ptr, val)
9497  U8G_ATOMIC_AND(ptr, val)
9498  U8G_ATOMIC_START();
9499  U8G_ATOMIC_END();
9500 
9501 */
9502 
9503 #if defined(ARDUINO)
9504 
9505 #define PIN_D0 UI_DISPLAY_D0_PIN
9506 #define PIN_D1 UI_DISPLAY_D1_PIN
9507 #define PIN_D2 UI_DISPLAY_D2_PIN
9508 #define PIN_D3 UI_DISPLAY_D3_PIN
9509 #define PIN_D4 UI_DISPLAY_D4_PIN
9510 #define PIN_D5 UI_DISPLAY_D5_PIN
9511 #define PIN_D6 UI_DISPLAY_D6_PIN
9512 #define PIN_D7 UI_DISPLAY_D7_PIN
9513 
9514 #define PIN_CS1 UI_DISPLAY_CS1
9515 #define PIN_CS2 UI_DISPLAY_CS2
9516 #define PIN_RW UI_DISPLAY_RW_PIN
9517 #define PIN_DI UI_DISPLAY_DI
9518 #define PIN_EN UI_DISPLAY_ENABLE_PIN
9519 
9520 //#define PIN_RESET
9521 
9522 
9523 #if defined(__PIC32MX)
9524 /* CHIPKIT PIC32 */
9525 static volatile uint32_t *u8g_data_port[8];
9526 static uint32_t u8g_data_mask[8];
9527 #else
9528 static volatile uint8_t *u8g_data_port[8];
9529 static uint8_t u8g_data_mask[8];
9530 #endif
9531 
9532 
9533 
9534 static void u8g_com_arduino_fast_parallel_init(u8g_t *u8g)
9535 {
9536  u8g_data_port[0] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));// added conversion for due to compile
9537  u8g_data_mask[0] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
9538  u8g_data_port[1] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));// added conversion for due to compile
9539  u8g_data_mask[1] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
9540  u8g_data_port[2] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));// added conversion for due to compile
9541  u8g_data_mask[2] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
9542  u8g_data_port[3] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));// added conversion for due to compile
9543  u8g_data_mask[3] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
9544 
9545  u8g_data_port[4] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4])); // added conversion for due to compile
9546  u8g_data_mask[4] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
9547  u8g_data_port[5] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));// added conversion for due to compile
9548  u8g_data_mask[5] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
9549  u8g_data_port[6] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));// added conversion for due to compile
9550  u8g_data_mask[6] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
9551  u8g_data_port[7] = (volatile uint8_t*)portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));// added conversion for due to compile
9552  u8g_data_mask[7] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);
9553 }
9554 
9555 /* atomic protection must be done by calling function */
9556 static void u8g_com_arduino_fast_write_data_pin(uint8_t pin, uint8_t val)
9557 {
9558  if ( val != 0 )
9559  *u8g_data_port[pin] |= u8g_data_mask[pin];
9560  else
9561  *u8g_data_port[pin] &= ~u8g_data_mask[pin];
9562 }
9563 
9564 
9565 void u8g_com_arduino_fast_parallel_write(u8g_t *u8g, uint8_t val)
9566 {
9567  U8G_ATOMIC_START();
9568  u8g_com_arduino_fast_write_data_pin( 0, val&1 );
9569  val >>= 1;
9570  u8g_com_arduino_fast_write_data_pin( 1, val&1 );
9571  val >>= 1;
9572  u8g_com_arduino_fast_write_data_pin( 2, val&1 );
9573  val >>= 1;
9574  u8g_com_arduino_fast_write_data_pin( 3, val&1 );
9575  val >>= 1;
9576 
9577  u8g_com_arduino_fast_write_data_pin( 4, val&1 );
9578  val >>= 1;
9579  u8g_com_arduino_fast_write_data_pin( 5, val&1 );
9580  val >>= 1;
9581  u8g_com_arduino_fast_write_data_pin( 6, val&1 );
9582  val >>= 1;
9583  u8g_com_arduino_fast_write_data_pin( 7, val&1 );
9584  val >>= 1;
9585  U8G_ATOMIC_END();
9586 
9587  /* EN cycle time must be 1 micro second */
9589  u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
9591  u8g_10MicroDelay(); /* ST7920 commands: 72us */
9592  u8g_10MicroDelay(); /* ST7920 commands: 72us */
9593 }
9594 
9595 
9596 uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9597 {
9598  switch(msg)
9599  {
9600  case U8G_COM_MSG_INIT:
9601  u8g_com_arduino_fast_parallel_init(u8g);
9602  /* setup the RW pin as output and force it to low */
9603  if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
9604  {
9605  pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
9607  }
9608  /* set all pins (except RW pin) */
9610  break;
9611  case U8G_COM_MSG_STOP:
9612  break;
9613 
9615  if ( arg_val == 0 )
9616  {
9617  /* disable */
9620  }
9621  else if ( arg_val == 1 )
9622  {
9623  /* enable */
9626  }
9627  else if ( arg_val == 2 )
9628  {
9629  /* enable */
9632  }
9633  else
9634  {
9635  /* enable */
9638  }
9639  break;
9641  u8g_com_arduino_fast_parallel_write(u8g, arg_val);
9642  break;
9643  case U8G_COM_MSG_WRITE_SEQ:
9644  {
9645  register uint8_t *ptr = (uint8_t*)arg_ptr;
9646  while( arg_val > 0 )
9647  {
9648  u8g_com_arduino_fast_parallel_write(u8g, *ptr++);
9649  arg_val--;
9650  }
9651  }
9652  break;
9654  {
9655  register uint8_t *ptr = (uint8_t*)arg_ptr;
9656  while( arg_val > 0 )
9657  {
9658  u8g_com_arduino_fast_parallel_write(u8g, u8g_pgm_read(ptr));
9659  ptr++;
9660  arg_val--;
9661  }
9662  }
9663  break;
9664  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
9666  break;
9667  case U8G_COM_MSG_RESET:
9668  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
9670  break;
9671 
9672  }
9673  return 1;
9674 }
9675 
9676 #else
9677 
9678 
9679 uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
9680 {
9681  return 1;
9682 }
9683 
9684 
9685 #endif /* ARDUINO */
9686 
9687 
9688 /*
9689 
9690  u8g_dev_st7565_nhd_c12864.c
9691 
9692  Support for the NHD-C12864A1Z-FSB-FBW (Newhaven Display)
9693 
9694  Universal 8bit Graphics Library
9695 
9696  Copyright (c) 2012, olikraus@gmail.com
9697  All rights reserved.
9698 
9699  Redistribution and use in source and binary forms, with or without modification,
9700  are permitted provided that the following conditions are met:
9701 
9702  * Redistributions of source code must retain the above copyright notice, this list
9703  of conditions and the following disclaimer.
9704 
9705  * Redistributions in binary form must reproduce the above copyright notice, this
9706  list of conditions and the following disclaimer in the documentation and/or other
9707  materials provided with the distribution.
9708 
9709  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
9710  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
9711  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9712  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9713  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
9714  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9715  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9716  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9717  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
9718  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9719  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9720  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9721  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9722 
9723 
9724 */
9725 
9726 #define WIDTH 128
9727 #define HEIGHT 64
9728 #define PAGE_HEIGHT 8
9729 
9730 const uint8_t u8g_dev_st7565_nhd_c12864_init_seq[] PROGMEM = {
9731  U8G_ESC_CS(0), /* disable chip */
9732  U8G_ESC_ADR(0), /* instruction mode */
9733  U8G_ESC_RST(10), /* do reset low pulse with (10*16)+2 milliseconds */
9734  U8G_ESC_CS(1), /* enable chip */
9735 
9736  0x040, /* set display start line */
9737  0x0a1, /* ADC set to reverse */
9738  0x0c0, /* common output mode: set scan direction normal operation */
9739  0x0a6, /* display normal, bit val 0: LCD pixel off. */
9740  0x0a2, /* LCD bias 1/9 */
9741  0x02f, /* all power control circuits on */
9742  0x0f8, /* set booster ratio to */
9743  0x000, /* 4x */
9744  0x027, /* set V0 voltage resistor ratio to large */
9745  0x081, /* set contrast */
9746  0x008, /* contrast: 0x008 is a good value for NHD C12864, Nov 2012: User reports that 0x1a is much better */
9747  0x0ac, /* indicator */
9748  0x000, /* disable */
9749  0x0af, /* display on */
9750 
9751  U8G_ESC_DLY(100), /* delay 100 ms */
9752  0x0a5, /* display all points, ST7565 */
9753  U8G_ESC_DLY(100), /* delay 100 ms */
9754  U8G_ESC_DLY(100), /* delay 100 ms */
9755  0x0a4, /* normal display */
9756  U8G_ESC_CS(0), /* disable chip */
9757  U8G_ESC_END /* end of sequence */
9758 };
9759 
9760 static const uint8_t u8g_dev_st7565_nhd_c12864_data_start[] PROGMEM = {
9761  U8G_ESC_ADR(0), /* instruction mode */
9762  U8G_ESC_CS(1), /* enable chip */
9763  0x010, /* set upper 4 bit of the col adr to 0 */
9764  0x004, /* set lower 4 bit of the col adr to 4 (NHD C12864) */
9765  U8G_ESC_END /* end of sequence */
9766 };
9767 
9768 static const uint8_t u8g_dev_st7565_c12864_sleep_on[] PROGMEM = {
9769  U8G_ESC_ADR(0), /* instruction mode */
9770  U8G_ESC_CS(1), /* enable chip */
9771  0x0ac, /* static indicator off */
9772  0x000, /* indicator register set (not sure if this is required) */
9773  0x0ae, /* display off */
9774  0x0a5, /* all points on */
9775  U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
9776  U8G_ESC_END /* end of sequence */
9777 };
9778 
9779 static const uint8_t u8g_dev_st7565_c12864_sleep_off[] PROGMEM = {
9780  U8G_ESC_ADR(0), /* instruction mode */
9781  U8G_ESC_CS(1), /* enable chip */
9782  0x0a4, /* all points off */
9783  0x0af, /* display on */
9784  U8G_ESC_DLY(50), /* delay 50 ms */
9785  U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
9786  U8G_ESC_END /* end of sequence */
9787 };
9788 
9789 uint8_t u8g_dev_st7565_nhd_c12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
9790 {
9791  switch(msg)
9792  {
9793  case U8G_DEV_MSG_INIT:
9794 #if defined(__SAM3X8E__)
9796 #else
9798 #endif
9799  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
9800  break;
9801  case U8G_DEV_MSG_STOP:
9802  break;
9803  case U8G_DEV_MSG_PAGE_NEXT:
9804  {
9805  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
9806  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
9807  u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
9808  u8g_SetAddress(u8g, dev, 1); /* data mode */
9809  if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
9810  return 0;
9811  u8g_SetChipSelect(u8g, dev, 0);
9812  }
9813  break;
9814  case U8G_DEV_MSG_CONTRAST:
9815  u8g_SetChipSelect(u8g, dev, 1);
9816  u8g_SetAddress(u8g, dev, 0); /* instruction mode */
9817  u8g_WriteByte(u8g, dev, 0x081);
9818  u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
9819  u8g_SetChipSelect(u8g, dev, 0);
9820  return 1;
9821  case U8G_DEV_MSG_SLEEP_ON:
9822  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);
9823  return 1;
9824  case U8G_DEV_MSG_SLEEP_OFF:
9825  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);
9826  return 1;
9827  }
9828  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
9829 }
9830 
9831 uint8_t u8g_dev_st7565_nhd_c12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
9832 {
9833  switch(msg)
9834  {
9835  case U8G_DEV_MSG_INIT:
9837  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
9838  break;
9839  case U8G_DEV_MSG_STOP:
9840  break;
9841  case U8G_DEV_MSG_PAGE_NEXT:
9842  {
9843  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
9844 
9845  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
9846  u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
9847  u8g_SetAddress(u8g, dev, 1); /* data mode */
9848  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t*)pb->buf);
9849  u8g_SetChipSelect(u8g, dev, 0);
9850 
9851  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
9852  u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
9853  u8g_SetAddress(u8g, dev, 1); /* data mode */
9854  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
9855  u8g_SetChipSelect(u8g, dev, 0);
9856  }
9857  break;
9858  case U8G_DEV_MSG_CONTRAST:
9859  u8g_SetChipSelect(u8g, dev, 1);
9860  u8g_SetAddress(u8g, dev, 0); /* instruction mode */
9861  u8g_WriteByte(u8g, dev, 0x081);
9862  u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
9863  u8g_SetChipSelect(u8g, dev, 0);
9864  return 1;
9865  case U8G_DEV_MSG_SLEEP_ON:
9866  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);
9867  return 1;
9868  case U8G_DEV_MSG_SLEEP_OFF:
9869  u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);
9870  return 1;
9871  }
9872  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
9873 }
9874 
9875 U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_SW_SPI);
9876 U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_HW_SPI);
9877 
9878 
9879 uint8_t u8g_dev_st7565_nhd_c12864_2x_buf[WIDTH*2] U8G_NOCOMMON ;
9880 u8g_pb_t u8g_dev_st7565_nhd_c12864_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_nhd_c12864_2x_buf};
9881 u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_sw_spi = { u8g_dev_st7565_nhd_c12864_2x_fn, &u8g_dev_st7565_nhd_c12864_2x_pb, U8G_COM_SW_SPI };
9882 u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_hw_spi = { u8g_dev_st7565_nhd_c12864_2x_fn, &u8g_dev_st7565_nhd_c12864_2x_pb, U8G_COM_HW_SPI };
9883 
9884 /*
9885 
9886  u8g_com_arduino_hw_spi.c
9887 
9888  Universal 8bit Graphics Library
9889 
9890  Copyright (c) 2011, olikraus@gmail.com
9891  All rights reserved.
9892 
9893  Redistribution and use in source and binary forms, with or without modification,
9894  are permitted provided that the following conditions are met:
9895 
9896  * Redistributions of source code must retain the above copyright notice, this list
9897  of conditions and the following disclaimer.
9898 
9899  * Redistributions in binary form must reproduce the above copyright notice, this
9900  list of conditions and the following disclaimer in the documentation and/or other
9901  materials provided with the distribution.
9902 
9903  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
9904  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
9905  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9906  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
9907  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
9908  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9909  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9910  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9911  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
9912  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
9913  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9914  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
9915  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9916 
9917  SPI Clock Cycle Type
9918 
9919  SSD1351 50ns 20 MHz
9920  SSD1322 300ns 3.3 MHz
9921  SSD1327 300ns
9922  SSD1306 300ns
9923  ST7565 400ns 2.5 MHz
9924  ST7920 400ns
9925 
9926  Arduino DUE
9927 
9928  PA25 MISO
9929  PA26 MOSI 75
9930  PA27 SCLK 76
9931 
9932 
9933 typedef struct {
9934  WoReg SPI_CR; (Spi Offset: 0x00) Control Register
9935  RwReg SPI_MR; (Spi Offset: 0x04) Mode Register
9936  RoReg SPI_RDR; (Spi Offset: 0x08) Receive Data Register
9937  WoReg SPI_TDR; (Spi Offset: 0x0C) Transmit Data Register
9938  RoReg SPI_SR; (Spi Offset: 0x10) Status Register
9939  WoReg SPI_IER; (Spi Offset: 0x14) Interrupt Enable Register
9940  WoReg SPI_IDR; (Spi Offset: 0x18) Interrupt Disable Register
9941  RoReg SPI_IMR; (Spi Offset: 0x1C) Interrupt Mask Register
9942  RoReg Reserved1[4];
9943  RwReg SPI_CSR[4]; (Spi Offset: 0x30) Chip Select Register
9944  RoReg Reserved2[41];
9945  RwReg SPI_WPMR; (Spi Offset: 0xE4) Write Protection Control Register
9946  RoReg SPI_WPSR; (Spi Offset: 0xE8) Write Protection Status Register
9947 } Spi;
9948 
9949  Power Management Controller (PMC)
9950  arduino-1.5.2/hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/include/instance/instance_pmc.h
9951  - enable PIO
9952 
9953  REG_PMC_PCER0 = 1UL << ID_PIOA
9954  - enable SPI
9955  REG_PMC_PCER0 = 1UL << ID_SPI0
9956 
9957 
9958  - enable PIOA and SPI0
9959  REG_PMC_PCER0 = (1UL << ID_PIOA) | (1UL << ID_SPI0);
9960 
9961  Parallel Input/Output Controller (PIO)
9962  arduino-1.5.2/hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/include/instance/instance_pioa.h
9963  - enable special function of the pin: disable PIO on A26 and A27:
9964  REG_PIOA_PDR = 0x0c000000
9965  PIOA->PIO_PDR = 0x0c000000
9966 
9967  SPI
9968  SPI0->SPI_CR = SPI_CR_SPIDIS
9969  SPI0->SPI_CR = SPI_CR_SWRST ;
9970  SPI0->SPI_CR = SPI_CR_SWRST ;
9971  SPI0->SPI_CR = SPI_CR_SPIEN
9972 
9973  Bit 0: Master Mode = 1 (active)
9974  Bit 1: Peripheral Select = 0 (fixed)
9975  Bit 2: Chip Select Decode Mode = 1 (4 to 16)
9976  Bit 4: Mode Fault Detection = 1 (disabled)
9977  Bit 5: Wait Data Read = 0 (disabled)
9978  Bit 7: Loop Back Mode = 0 (disabled)
9979  Bit 16-19: Peripheral Chip Select = 0 (chip select 0)
9980  SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PCSDEC | SPI_MR_MODFDIS
9981 
9982  Bit 0: Clock Polarity = 0
9983  Bit 1: Clock Phase = 0
9984  Bit 4-7: Bits = 0 (8 Bit)
9985  Bit 8-15: SCBR = 1
9986  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(x) Serial Baud Rate
9987  SCBR / 84000000 > 50 / 1000000000
9988  SCBR / 84 > 5 / 100
9989  SCBR > 50 *84 / 1000 --> SCBR=5
9990  SCBR > 300*84 / 1000 --> SCBR=26
9991  SCBR > 400*84 / 1000 --> SCBR=34
9992 
9993  Arduino Due test code:
9994  REG_PMC_PCER0 = (1UL << ID_PIOA) | (1UL << ID_SPI0);
9995  REG_PIOA_PDR = 0x0c000000;
9996  SPI0->SPI_CR = SPI_CR_SPIDIS;
9997  SPI0->SPI_CR = SPI_CR_SWRST;
9998  SPI0->SPI_CR = SPI_CR_SWRST;
9999  SPI0->SPI_CR = SPI_CR_SPIEN;
10000  SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PCSDEC | SPI_MR_MODFDIS;
10001  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(30);
10002 
10003  for(;;)
10004  {
10005  while( (SPI0->SPI_SR & SPI_SR_TDRE) == 0 )
10006  ;
10007  SPI0->SPI_TDR = 0x050;
10008  }
10009 
10010 */
10011 
10012 #if defined(ARDUINO)
10013 
10014 #if defined(__AVR__)
10015 #define U8G_ARDUINO_ATMEGA_HW_SPI
10016 /* remove the definition for attiny */
10017 #if __AVR_ARCH__ == 2
10018 #undef U8G_ARDUINO_ATMEGA_HW_SPI
10019 #endif
10020 #if __AVR_ARCH__ == 25
10021 #undef U8G_ARDUINO_ATMEGA_HW_SPI
10022 #endif
10023 #endif
10024 
10025 #if defined(U8G_ARDUINO_ATMEGA_HW_SPI)
10026 
10027 //#include <avr/interrupt.h>
10028 //#include <avr/io.h>
10029 
10030 #if ARDUINO < 100
10031 
10032 /* fixed pins */
10033 #if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) // Sanguino.cc board
10034 #define PIN_SCK 7
10035 #define PIN_MISO 6
10036 #define PIN_MOSI 5
10037 #define PIN_CS 4
10038 #else // Arduino Board
10039 #define PIN_SCK 13
10040 #define PIN_MISO 12
10041 #define PIN_MOSI 11
10042 #define PIN_CS 10
10043 #endif // (__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
10044 
10045 #else
10046 
10047 /* use Arduino pin definitions */
10048 #define PIN_SCK SCK
10049 #define PIN_MISO MISO_PIN
10050 #define PIN_MOSI MOSI_PIN
10051 #define PIN_CS SS
10052 
10053 #endif
10054 
10055 
10056 
10057 //static uint8_t u8g_spi_out(uint8_t data) U8G_NOINLINE;
10058 static uint8_t u8g_spi_out(uint8_t data)
10059 {
10060  /* unsigned char x = 100; */
10061  /* send data */
10062  SPDR = data;
10063  /* wait for transmission */
10064  while (!(SPSR & (1<<SPIF)))
10065  ;
10066  /* clear the SPIF flag by reading SPDR */
10067  return SPDR;
10068 }
10069 
10070 
10071 uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
10072 {
10073  switch(msg)
10074  {
10075  case U8G_COM_MSG_STOP:
10076  break;
10077 
10078  case U8G_COM_MSG_INIT:
10080  pinMode(PIN_SCK, OUTPUT);
10081  digitalWrite(PIN_SCK, LOW);
10082  pinMode(PIN_MOSI, OUTPUT);
10083  digitalWrite(PIN_MOSI, LOW);
10084  /* pinMode(PIN_MISO, INPUT); */
10085 
10086  pinMode(PIN_CS, OUTPUT); /* system chip select for the atmega board */
10087  digitalWrite(PIN_CS, HIGH);
10088 
10089 
10090 
10091  /*
10092  SPR1 SPR0
10093  0 0 fclk/4
10094  0 1 fclk/16
10095  1 0 fclk/64
10096  1 1 fclk/128
10097  */
10098  SPCR = 0;
10099  SPCR = (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
10100 #ifdef U8G_HW_SPI_2X
10101  SPSR = (1 << SPI2X); /* double speed, issue 89 */
10102 #else
10103  if ( arg_val <= U8G_SPI_CLK_CYCLE_50NS )
10104  {
10105  SPSR = (1 << SPI2X); /* double speed, issue 89 */
10106  }
10107 #endif
10108 
10109 
10110  break;
10111 
10112  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
10114  break;
10115 
10117  if ( arg_val == 0 )
10118  {
10119  /* disable */
10121  }
10122  else
10123  {
10124  /* enable */
10127  }
10128  break;
10129 
10130  case U8G_COM_MSG_RESET:
10131  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
10133  break;
10134 
10136  u8g_spi_out(arg_val);
10137  break;
10138 
10139  case U8G_COM_MSG_WRITE_SEQ:
10140  {
10141  register uint8_t *ptr = (uint8_t*)arg_ptr;
10142  while( arg_val > 0 )
10143  {
10144  u8g_spi_out(*ptr++);
10145  arg_val--;
10146  }
10147  }
10148  break;
10150  {
10151  register uint8_t *ptr = (uint8_t*)arg_ptr;
10152  while( arg_val > 0 )
10153  {
10154  u8g_spi_out(u8g_pgm_read(ptr));
10155  ptr++;
10156  arg_val--;
10157  }
10158  }
10159  break;
10160  }
10161  return 1;
10162 }
10163 
10164 /* #elif defined(__18CXX) || defined(__PIC32MX) */
10165 
10166 #elif defined(__SAM3X8E__) // Arduino Due, maybe we should better check for __SAM3X8E__
10167 
10168 /* use Arduino pin definitions */
10169 #define PIN_SCK SCK
10170 #define PIN_MISO MISO
10171 #define PIN_MOSI MOSI
10172 #define PIN_CS SS
10173 
10174 
10175 static uint8_t u8g_spi_out(uint8_t data)
10176 {
10177  /* wait until tx register is empty */
10178  while( (SPI0->SPI_SR & SPI_SR_TDRE) == 0 )
10179  ;
10180  /* send data */
10181  SPI0->SPI_TDR = (uint32_t)data;
10182  return data;
10183 }
10184 
10185 
10186 uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
10187 {
10188  switch(msg)
10189  {
10190  case U8G_COM_MSG_STOP:
10191  break;
10192 
10193  case U8G_COM_MSG_INIT:
10196 
10197  /* Arduino Due specific code */
10198 
10199  /* enable PIOA and SPI0 */
10200  REG_PMC_PCER0 = (1UL << ID_PIOA) | (1UL << ID_SPI0);
10201 
10202  /* disable PIO on A26 and A27 */
10203  REG_PIOA_PDR = 0x0c000000;
10204 
10205  /* reset SPI0 (from sam lib) */
10206  SPI0->SPI_CR = SPI_CR_SPIDIS;
10207  SPI0->SPI_CR = SPI_CR_SWRST;
10208  SPI0->SPI_CR = SPI_CR_SWRST;
10209  SPI0->SPI_CR = SPI_CR_SPIEN;
10210  u8g_MicroDelay();
10211 
10212  /* master mode, no fault detection, chip select 0 */
10213  SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PCSDEC | SPI_MR_MODFDIS;
10214 
10215  /* Polarity, Phase, 8 Bit data transfer, baud rate */
10216  /* x * 1000 / 84 --> clock cycle in ns
10217  5 * 1000 / 84 = 58 ns
10218  SCBR > 50 *84 / 1000 --> SCBR=5
10219  SCBR > 300*84 / 1000 --> SCBR=26
10220  SCBR > 400*84 / 1000 --> SCBR=34
10221  */
10222 
10223  if ( arg_val <= U8G_SPI_CLK_CYCLE_50NS )
10224  {
10225  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(5) | 1;
10226  }
10227  else if ( arg_val <= U8G_SPI_CLK_CYCLE_300NS )
10228  {
10229  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(26) | 1;
10230  }
10231  else if ( arg_val <= U8G_SPI_CLK_CYCLE_400NS )
10232  {
10233  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(34) | 1;
10234  }
10235  else if ( arg_val <= U8G_SPI_CLK_CYCLE_500NS )
10236  {
10237  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(42) | 1;
10238  }
10239  else
10240  {
10241  SPI0->SPI_CSR[0] = SPI_CSR_SCBR(84) | 1;
10242  }
10243 
10244  u8g_MicroDelay();
10245  break;
10246 
10247  case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
10249  u8g_MicroDelay();
10250  break;
10251 
10253  if ( arg_val == 0 )
10254  {
10255  /* disable */
10256  u8g_MicroDelay(); /* this delay is required to avoid that the display is switched off too early --> DOGS102 with DUE */
10258  u8g_MicroDelay();
10259  }
10260  else
10261  {
10262  /* enable */
10263  //u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
10265  u8g_MicroDelay();
10266  }
10267  break;
10268 
10269  case U8G_COM_MSG_RESET:
10270  if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
10272  break;
10273 
10275  u8g_spi_out(arg_val);
10276  u8g_MicroDelay();
10277  break;
10278 
10279  case U8G_COM_MSG_WRITE_SEQ:
10280  {
10281  register uint8_t *ptr = (uint8_t*)arg_ptr;
10282  while( arg_val > 0 )
10283  {
10284  u8g_spi_out(*ptr++);
10285  arg_val--;
10286  }
10287  }
10288  break;
10290  {
10291  register uint8_t *ptr = (uint8_t*)arg_ptr;
10292  while( arg_val > 0 )
10293  {
10294  u8g_spi_out(u8g_pgm_read(ptr));
10295  ptr++;
10296  arg_val--;
10297  }
10298  }
10299  break;
10300  }
10301  return 1;
10302 }
10303 
10304 
10305 
10306 #else /* U8G_ARDUINO_ATMEGA_HW_SPI */
10307 
10308 #endif /* U8G_ARDUINO_ATMEGA_HW_SPI */
10309 
10310 #else /* ARDUINO */
10311 
10312 uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
10313 {
10314  return 1;
10315 }
10316 
10317 #endif /* ARDUINO */
10318 
10319 /*
10320 
10321  u8g_rot.c
10322 
10323  Universal 8bit Graphics Library
10324 
10325  Copyright (c) 2011, olikraus@gmail.com
10326  All rights reserved.
10327 
10328  Redistribution and use in source and binary forms, with or without modification,
10329  are permitted provided that the following conditions are met:
10330 
10331  * Redistributions of source code must retain the above copyright notice, this list
10332  of conditions and the following disclaimer.
10333 
10334  * Redistributions in binary form must reproduce the above copyright notice, this
10335  list of conditions and the following disclaimer in the documentation and/or other
10336  materials provided with the distribution.
10337 
10338  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
10339  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
10340  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10341  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10342  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
10343  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10344  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
10345  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10346  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
10347  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
10348  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
10349  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
10350  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10351 
10352 
10353 */
10354 
10355 uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
10356 uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
10357 uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
10358 
10359 uint8_t u8g_dev_rot_dummy_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10360 {
10361  return 0;
10362 }
10363 
10365 
10366 
10368 {
10369  if ( u8g->dev != &u8g_dev_rot )
10370  return;
10371  u8g->dev = (u8g_dev_t*)u8g_dev_rot.dev_mem;
10372  u8g_UpdateDimension(u8g);
10373 }
10374 
10376 {
10377  if ( u8g->dev != &u8g_dev_rot )
10378  {
10379  u8g_dev_rot.dev_mem = u8g->dev;
10380  u8g->dev = &u8g_dev_rot;
10381  }
10382  u8g_dev_rot.dev_fn = u8g_dev_rot90_fn;
10383  u8g_UpdateDimension(u8g);
10384 }
10385 
10387 {
10388  if ( u8g->dev != &u8g_dev_rot )
10389  {
10390  u8g_dev_rot.dev_mem = u8g->dev;
10391  u8g->dev = &u8g_dev_rot;
10392  }
10393  u8g_dev_rot.dev_fn = u8g_dev_rot180_fn;
10394  u8g_UpdateDimension(u8g);
10395 }
10396 
10398 {
10399  if ( u8g->dev != &u8g_dev_rot )
10400  {
10401  u8g_dev_rot.dev_mem = u8g->dev;
10402  u8g->dev = &u8g_dev_rot;
10403  }
10404  u8g_dev_rot.dev_fn = u8g_dev_rot270_fn;
10405  u8g_UpdateDimension(u8g);
10406 }
10407 
10408 uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10409 {
10410  u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
10411  switch(msg)
10412  {
10413  default:
10414  /*
10415  case U8G_DEV_MSG_INIT:
10416  case U8G_DEV_MSG_STOP:
10417  case U8G_DEV_MSG_PAGE_FIRST:
10418  case U8G_DEV_MSG_PAGE_NEXT:
10419  case U8G_DEV_MSG_SET_COLOR_ENTRY:
10420  case U8G_DEV_MSG_SET_XY_CB:
10421  */
10422  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10423 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
10424  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
10425  {
10426  u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
10427  u8g_uint_t x, y, tmp;
10428 
10429  /* transform the reference point */
10430  y = bbx->x;
10431  x = u8g->height;
10432  /* x = u8g_GetWidthLL(u8g, rotation_chain); */
10433  x -= bbx->y;
10434  x--;
10435 
10436  /* adjust point to be the uppler left corner again */
10437  x -= bbx->h;
10438  x++;
10439 
10440  /* swap box dimensions */
10441  tmp = bbx->w;
10442  bbx->w = bbx->h;
10443  bbx->h = tmp;
10444 
10445  /* store x,y */
10446  bbx->x = x;
10447  bbx->y = y;
10448  }
10449  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10450 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
10452  /* get page size from next device in the chain */
10453  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10454  //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10455  {
10456  u8g_box_t new_box;
10457  //new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
10458  //new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
10459 
10460  new_box.x0 = ((u8g_box_t *)arg)->y0;
10461  new_box.x1 = ((u8g_box_t *)arg)->y1;
10462  new_box.y0 = ((u8g_box_t *)arg)->x0;
10463  new_box.y1 = ((u8g_box_t *)arg)->x1;
10464  *((u8g_box_t *)arg) = new_box;
10465  //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10466  }
10467  break;
10468  case U8G_DEV_MSG_GET_WIDTH:
10469  *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
10470  break;
10472  *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
10473  break;
10474  case U8G_DEV_MSG_SET_PIXEL:
10476  {
10477  u8g_uint_t x, y;
10478  y = ((u8g_dev_arg_pixel_t *)arg)->x;
10479  x = u8g_GetWidthLL(u8g, rotation_chain);
10480  x -= ((u8g_dev_arg_pixel_t *)arg)->y;
10481  x--;
10482  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10483  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10484  }
10485  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10486  break;
10489  {
10490  u8g_uint_t x, y;
10491  //uint16_t x,y;
10492  y = ((u8g_dev_arg_pixel_t *)arg)->x;
10493  x = u8g_GetWidthLL(u8g, rotation_chain);
10494  x -= ((u8g_dev_arg_pixel_t *)arg)->y;
10495  x--;
10496  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10497  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10498  ((u8g_dev_arg_pixel_t *)arg)->dir+=1;
10499  ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
10500  }
10501  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10502  break;
10503  }
10504  return 1;
10505 }
10506 
10507 uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10508 {
10509  u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
10510  switch(msg)
10511  {
10512  default:
10513  /*
10514  case U8G_DEV_MSG_INIT:
10515  case U8G_DEV_MSG_STOP:
10516  case U8G_DEV_MSG_PAGE_FIRST:
10517  case U8G_DEV_MSG_PAGE_NEXT:
10518  case U8G_DEV_MSG_SET_COLOR_ENTRY:
10519  case U8G_DEV_MSG_SET_XY_CB:
10520  */
10521  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10522 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
10523  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
10524  {
10525  u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
10526  u8g_uint_t x, y;
10527 
10528  /* transform the reference point */
10529  //y = u8g_GetHeightLL(u8g, rotation_chain);
10530  y = u8g->height;
10531  y -= bbx->y;
10532  y--;
10533 
10534  //x = u8g_GetWidthLL(u8g, rotation_chain);
10535  x = u8g->width;
10536  x -= bbx->x;
10537  x--;
10538 
10539  /* adjust point to be the uppler left corner again */
10540  y -= bbx->h;
10541  y++;
10542 
10543  x -= bbx->w;
10544  x++;
10545 
10546  /* store x,y */
10547  bbx->x = x;
10548  bbx->y = y;
10549  }
10550  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10551 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
10553  /* get page size from next device in the chain */
10554  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10555  //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10556  {
10557  u8g_box_t new_box;
10558 
10559  new_box.x0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
10560  new_box.x1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
10561  new_box.y0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
10562  new_box.y1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
10563  *((u8g_box_t *)arg) = new_box;
10564  //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10565  }
10566  break;
10567  case U8G_DEV_MSG_GET_WIDTH:
10568  *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g,rotation_chain);
10569  break;
10571  *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g, rotation_chain);
10572  break;
10573  case U8G_DEV_MSG_SET_PIXEL:
10575  {
10576  u8g_uint_t x, y;
10577 
10578  y = u8g_GetHeightLL(u8g, rotation_chain);
10579  y -= ((u8g_dev_arg_pixel_t *)arg)->y;
10580  y--;
10581 
10582  x = u8g_GetWidthLL(u8g, rotation_chain);
10583  x -= ((u8g_dev_arg_pixel_t *)arg)->x;
10584  x--;
10585 
10586  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10587  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10588  }
10589  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10590  break;
10593  {
10594  u8g_uint_t x, y;
10595 
10596  y = u8g_GetHeightLL(u8g, rotation_chain);
10597  y -= ((u8g_dev_arg_pixel_t *)arg)->y;
10598  y--;
10599 
10600  x = u8g_GetWidthLL(u8g, rotation_chain);
10601  x -= ((u8g_dev_arg_pixel_t *)arg)->x;
10602  x--;
10603 
10604  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10605  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10606  ((u8g_dev_arg_pixel_t *)arg)->dir+=2;
10607  ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
10608  }
10609  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10610  break;
10611  }
10612  return 1;
10613 }
10614 
10615 uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10616 {
10617  u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
10618  switch(msg)
10619  {
10620  default:
10621  /*
10622  case U8G_DEV_MSG_INIT:
10623  case U8G_DEV_MSG_STOP:
10624  case U8G_DEV_MSG_PAGE_FIRST:
10625  case U8G_DEV_MSG_PAGE_NEXT:
10626  case U8G_DEV_MSG_SET_COLOR_ENTRY:
10627  case U8G_DEV_MSG_SET_XY_CB:
10628  */
10629  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10630 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
10631  case U8G_DEV_MSG_IS_BBX_INTERSECTION:
10632  {
10633  u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
10634  u8g_uint_t x, y, tmp;
10635 
10636  /* transform the reference point */
10637  x = bbx->y;
10638 
10639  y = u8g->width;
10640  /* y = u8g_GetHeightLL(u8g, rotation_chain); */
10641  y -= bbx->x;
10642  y--;
10643 
10644  /* adjust point to be the uppler left corner again */
10645  y -= bbx->w;
10646  y++;
10647 
10648  /* swap box dimensions */
10649  tmp = bbx->w;
10650  bbx->w = bbx->h;
10651  bbx->h = tmp;
10652 
10653  /* store x,y */
10654  bbx->x = x;
10655  bbx->y = y;
10656  }
10657  return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10658 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
10660  /* get page size from next device in the chain */
10661  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10662  //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10663  {
10664  u8g_box_t new_box;
10665 
10666  new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
10667  new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
10668  new_box.y0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
10669  new_box.y1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
10670  *((u8g_box_t *)arg) = new_box;
10671  //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
10672  }
10673  break;
10674  case U8G_DEV_MSG_GET_WIDTH:
10675  *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
10676  break;
10678  *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
10679  break;
10680  case U8G_DEV_MSG_SET_PIXEL:
10682  {
10683  u8g_uint_t x, y;
10684  x = ((u8g_dev_arg_pixel_t *)arg)->y;
10685 
10686  y = u8g_GetHeightLL(u8g, rotation_chain);
10687  y -= ((u8g_dev_arg_pixel_t *)arg)->x;
10688  y--;
10689 
10690  /*
10691  x = u8g_GetWidthLL(u8g, rotation_chain);
10692  x -= ((u8g_dev_arg_pixel_t *)arg)->y;
10693  x--;
10694  */
10695  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10696  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10697  }
10698  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10699  break;
10702  {
10703  u8g_uint_t x, y;
10704  x = ((u8g_dev_arg_pixel_t *)arg)->y;
10705 
10706  y = u8g_GetHeightLL(u8g, rotation_chain);
10707  y -= ((u8g_dev_arg_pixel_t *)arg)->x;
10708  y--;
10709 
10710  /*
10711  x = u8g_GetWidthLL(u8g, rotation_chain);
10712  x -= ((u8g_dev_arg_pixel_t *)arg)->y;
10713  x--;
10714  */
10715  ((u8g_dev_arg_pixel_t *)arg)->x = x;
10716  ((u8g_dev_arg_pixel_t *)arg)->y = y;
10717  ((u8g_dev_arg_pixel_t *)arg)->dir+=3;
10718  ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
10719  }
10720  u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
10721  break;
10722  }
10723  return 1;
10724 }
10725 
10726 uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
10727 {
10728  switch(msg)
10729  {
10730  case U8G_COM_MSG_INIT:
10731  break;
10732  case U8G_COM_MSG_STOP:
10733  break;
10734 
10735 
10737  /* arg_val contains the chip number, which should be enabled */
10738  break;
10739 
10740 
10742  break;
10743  case U8G_COM_MSG_WRITE_SEQ:
10744  break;
10745  }
10746  return 1;
10747 }
10748 /*
10749  u8g_dev_uc1701_mini12864.c (dealextreme)
10750  Universal 8bit Graphics Library
10751 
10752  Copyright (c) 2011, olikraus@gmail.com
10753  All rights reserved.
10754  Redistribution and use in source and binary forms, with or without modification,
10755  are permitted provided that the following conditions are met:
10756  * Redistributions of source code must retain the above copyright notice, this list
10757  of conditions and the following disclaimer.
10758 
10759  * Redistributions in binary form must reproduce the above copyright notice, this
10760  list of conditions and the following disclaimer in the documentation and/or other
10761  materials provided with the distribution.
10762  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
10763  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
10764  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10765  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10766  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
10767  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10768  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
10769  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10770  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
10771  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
10772  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
10773  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
10774  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10775 
10776 
10777 */
10778 
10779 #undef WIDTH
10780 #undef HEIGHT
10781 #undef PAGE_HEIGHT
10782 #define WIDTH 128
10783 #define HEIGHT 64
10784 #define PAGE_HEIGHT 8
10785 
10786 static const uint8_t u8g_dev_uc1701_mini12864_init_seq[] PROGMEM = {
10787  U8G_ESC_CS(0), /* disable chip */
10788  U8G_ESC_ADR(0), /* instruction mode */
10789  U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
10790  U8G_ESC_CS(1), /* enable chip */
10791 
10792  0x0e2, /* soft reset */
10793  0x040, /* set display start line to 0 */
10794  0x0a0, /* ADC set to reverse */
10795  0x0c8, /* common output mode */
10796  0x0a6, /* display normal, bit val 0: LCD pixel off. */
10797  0x0a2, /* LCD bias 1/9 */
10798  0x02f, /* all power control circuits on */
10799  0x0f8, /* set booster ratio to */
10800  0x000, /* 4x */
10801  0x023, /* set V0 voltage resistor ratio to large */
10802  0x081, /* set contrast */
10803  0x027, /* contrast value */
10804  0x0ac, /* indicator */
10805  0x000, /* disable */
10806  0x0af, /* display on */
10807 
10808  U8G_ESC_DLY(100), /* delay 100 ms */
10809  0x0a5, /* display all points, ST7565 */
10810  U8G_ESC_DLY(100), /* delay 100 ms */
10811  U8G_ESC_DLY(100), /* delay 100 ms */
10812  0x0a4, /* normal display */
10813  U8G_ESC_CS(0), /* disable chip */
10814  U8G_ESC_END /* end of sequence */
10815 };
10816 
10817 static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = {
10818  U8G_ESC_ADR(0), /* instruction mode */
10819  U8G_ESC_CS(1), /* enable chip */
10820  0x010, /* set upper 4 bit of the col adr to 0 */
10821  0x000, /* set lower 4 bit of the col adr to 4 */
10822  U8G_ESC_END /* end of sequence */
10823 };
10824 
10825 uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10826 {
10827  switch(msg)
10828  {
10829  case U8G_DEV_MSG_INIT:
10831  u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
10832  break;
10833  case U8G_DEV_MSG_STOP:
10834  break;
10835  case U8G_DEV_MSG_PAGE_NEXT:
10836  {
10837  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
10838  u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
10839  u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page */
10840  u8g_SetAddress(u8g, dev, 1); /* data mode */
10841  if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
10842  return 0;
10843  u8g_SetChipSelect(u8g, dev, 0);
10844  }
10845  break;
10846  case U8G_DEV_MSG_CONTRAST:
10847  u8g_SetChipSelect(u8g, dev, 1);
10848  u8g_SetAddress(u8g, dev, 0); /* instruction mode */
10849  u8g_WriteByte(u8g, dev, 0x081);
10850  u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
10851  u8g_SetChipSelect(u8g, dev, 0);
10852  return 1;
10853  }
10854  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
10855 }
10856 
10857 uint8_t u8g_dev_uc1701_mini12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
10858 {
10859  switch(msg)
10860  {
10861  case U8G_DEV_MSG_INIT:
10863  u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
10864  break;
10865  case U8G_DEV_MSG_STOP:
10866  break;
10867  case U8G_DEV_MSG_PAGE_NEXT:
10868  {
10869  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
10870 
10871  u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
10872  u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page */
10873  u8g_SetAddress(u8g, dev, 1); /* data mode */
10874  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t*)pb->buf);
10875  u8g_SetChipSelect(u8g, dev, 0);
10876 
10877  u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
10878  u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page */
10879  u8g_SetAddress(u8g, dev, 1); /* data mode */
10880  u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
10881  u8g_SetChipSelect(u8g, dev, 0);
10882  }
10883  break;
10884  case U8G_DEV_MSG_CONTRAST:
10885  u8g_SetChipSelect(u8g, dev, 1);
10886  u8g_SetAddress(u8g, dev, 0); /* instruction mode */
10887  u8g_WriteByte(u8g, dev, 0x081);
10888  u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
10889  u8g_SetChipSelect(u8g, dev, 0);
10890  return 1;
10891  }
10892  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
10893 }
10894 
10895 U8G_PB_DEV(u8g_dev_uc1701_mini12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_SW_SPI);
10896 U8G_PB_DEV(u8g_dev_uc1701_mini12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_HW_SPI);
10897 
10898 uint8_t u8g_dev_uc1701_mini12864_2x_buf[WIDTH*2] U8G_NOCOMMON ;
10899 u8g_pb_t u8g_dev_uc1701_mini12864_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1701_mini12864_2x_buf};
10900 u8g_dev_t u8g_dev_uc1701_mini12864_2x_sw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_SW_SPI };
10901 u8g_dev_t u8g_dev_uc1701_mini12864_2x_hw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_HW_SPI };
10902 
10903 #pragma GCC diagnostic push
u8g_dev_t u8g_dev_sdl_2bit
u8g_dev_t u8g_dev_sbn1661_122x32
uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding)
Definition: u8glib_ex.h:3466
void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
Definition: u8glib_ex.h:5195
u8g_dev_t u8g_dev_st7565_lm6063_sw_spi
u8g_dev_fnptr dev_fn
Definition: u8glib_ex.h:321
uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:4842
void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
Definition: u8glib_ex.h:5674
uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
Definition: u8glib_ex.h:5902
u8g_dev_t u8g_dev_st7565_lm6059_2x_sw_spi
#define U8G_PI_D2
Definition: u8glib_ex.h:1087
void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
Definition: u8glib_ex.h:5731
uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
#define U8G_SPI_CLK_CYCLE_400NS
Definition: u8glib_ex.h:876
static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
Definition: u8glib_ex.h:7915
static int8_t u8g_font_GetBBXOffX(const void *font)
Definition: u8glib_ex.h:3183
#define U8G_DEV_MSG_SET_COLOR_ENTRY
Definition: u8glib_ex.h:671
u8g_dev_t u8g_dev_flipdisc_2x7
u8g_dev_t u8g_dev_st7565_64128n_parallel
uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
#define U8G_PI_D7
Definition: u8glib_ex.h:1094
static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
Definition: u8glib_ex.h:5169
u8g_dev_t u8g_dev_st7565_64128n_sw_spi
u8g_dev_t u8g_dev_ssd1306_128x32_2x_hw_spi
u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:3981
uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:8621
void * buf
Definition: u8glib_ex.h:958
uint8_t cursor_bg_color
Definition: u8glib_ex.h:1119
u8g_dev_t u8g_dev_st7565_dogm128_hw_spi
void u8g_SetDefaultBackgroundColor(u8g_t *u8g)
Definition: u8glib_ex.h:5804
#define U8G_COM_PARALLEL
Definition: u8glib_ex.h:848
int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
#define PROGMEM
Definition: u8glib_ex.h:239
u8g_dev_t u8g_dev_pbm
#define U8G_I2C_ERR_NONE
Definition: u8glib_ex.h:1421
u8g_dev_t u8g_dev_uc1701_mini12864_sw_spi
Definition: u8glib_ex.h:377
uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
u8g_dev_t u8g_dev_st7920_192x32_hw_spi
u8g_uint_t g
Definition: u8glib_ex.h:634
#define U8G_COM_MSG_WRITE_BYTE
Definition: u8glib_ex.h:717
void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g)
u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_sw_spi
Definition: u8glib_ex.h:9881
void u8g_SetFontPosBaseline(u8g_t *u8g)
Definition: u8glib_ex.h:4085
u8g_dev_t u8g_dev_ssd1306_128x32_2x_i2c
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi
u8g_uint_t width
Definition: u8glib_ex.h:957
#define U8G_COM_MSG_INIT
Definition: u8glib_ex.h:708
uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10615
u8g_dev_t u8g_dev_st7565_lm6059_sw_spi
#define U8G_DEV_MSG_PAGE_NEXT
Definition: u8glib_ex.h:650
u8g_dev_t u8g_dev_st7565_64128n_2x_parallel
uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
#define PAGE_HEIGHT
Definition: u8glib_ex.h:10784
int8_t u8g_GetFontBBXOffY(u8g_t *u8g)
Definition: u8glib_ex.h:3310
static uint8_t * u8g_font_GetGlyphDataStart(const void *font, u8g_glyph_t g)
Definition: u8glib_ex.h:3247
void u8g_SetVirtualScreenDimension(u8g_t *vs_u8g, u8g_uint_t width, u8g_uint_t height)
u8g_uint_t y
Definition: u8glib_ex.h:622
#define U8G_DEV_MSG_STOP
Definition: u8glib_ex.h:641
uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
char u8g_font_get_char(const void *s)
Definition: u8glib_ex.h:4140
u8g_dev_t u8g_dev_uc1610_dogxl160_gr_hw_spi
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) U8G_NOINLINE
Definition: u8glib_ex.h:8468
u8g_dev_t u8g_dev_ssd1306_128x64_i2c
#define U8G_PI_D6
Definition: u8glib_ex.h:1093
#define U8G_SPI_CLK_CYCLE_500NS
Definition: u8glib_ex.h:877
Definition: u8glib_ex.h:606
uint8_t u8g_i2c_start(uint8_t sla) U8G_NOINLINE
Definition: u8glib_ex.h:8473
uint8_t hi_color
Definition: u8glib_ex.h:612
uint8_t u8g_dev_rot_dummy_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10359
void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font)
Definition: u8glib_ex.h:4461
int8_t u8g_draw_aa_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:4474
void u8g_pb8h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
Definition: u8glib_ex.h:6639
u8g_dev_t u8g_dev_st7920_202x32_hw_spi
u8g_dev_t u8g_dev_st7565_dogm132_hw_spi
u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi
u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:3964
void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
uint8_t u8g_is_box_bbx_intersection(u8g_box_t *box, u8g_dev_arg_bbx_t *bbx)
#define U8G_STATE_MSG_GET_IDX(msg)
Definition: u8glib_ex.h:1227
u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
Definition: u8glib_ex.h:3910
u8g_dev_t u8g_dev_uc1601_c128032_sw_spi
u8g_dev_t u8g_dev_a2_micro_printer_192x120_ds
u8g_dev_t u8g_dev_sdl_hicolor
#define U8G_FONT_HEIGHT_MODE_XTEXT
Definition: u8glib_ex.h:1107
u8g_uint_t r
Definition: u8glib_ex.h:634
#define U8G_COM_SSD_I2C
Definition: u8glib_ex.h:866
u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s)
Definition: u8glib_ex.h:4215
void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE
Definition: u8glib_ex.h:6559
uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:6723
u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi
u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g)
Definition: u8glib_ex.h:4102
u8g_dev_t u8g_dev_st7565_lm6059_hw_spi
#define u8g_dev_ssd1306_128x64_init_seq
Definition: u8glib_ex.h:2810
u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
Definition: u8glib_ex.h:3876
u8g_dev_t u8g_dev_ssd1351_128x128_332_sw_spi
void u8g_SetFontPosTop(u8g_t *u8g)
Definition: u8glib_ex.h:4116
uint8_t u8g_dev_pbxh24_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
u8g_dev_t u8g_dev_ssd1309_128x64_sw_spi
void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
uint8_t u8g_GetColorIndex(u8g_t *u8g)
Definition: u8glib_ex.h:5768
u8g_dev_t u8g_dev_ks0108_128x64
void u8g_DisableCom(u8g_t *u8g, u8g_dev_t *dev)
uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g)
Definition: u8glib_ex.h:3316
static void u8g_CopyGlyphDataToCache(u8g_t *u8g, u8g_glyph_t g)
Definition: u8glib_ex.h:3324
u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5388
void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE
u8g_dev_t u8g_dev_ssd1306_128x32_i2c
void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
Definition: u8glib_ex.h:4442
u8g_dev_t u8g_dev_lc7981_240x64_8bit
#define U8G_I2C_OPT_NO_ACK
Definition: u8glib_ex.h:1413
uint8_t u8g_dev_pbxh16_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
u8g_dev_t u8g_dev_ssd1306_128x64_hw_spi
static uint8_t u8g_i2c_err_code
Definition: u8glib_ex.h:7889
#define u8g_pgm_read(adr)
Definition: u8glib_ex.h:242
#define U8G_PI_A0
Definition: u8glib_ex.h:1063
#define U8G_DEV_MSG_SET_PIXEL
Definition: u8glib_ex.h:668
#define U8G_PI_D0
Definition: u8glib_ex.h:1082
void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height) U8G_NOINLINE
Definition: u8glib_ex.h:4592
u8g_dev_t u8g_dev_pbm_8h2
u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
Definition: u8glib_ex.h:3998
#define U8G_I2C_OPT_DEV_1
Definition: u8glib_ex.h:1415
void u8g_font_GetStrSizeP(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height)
#define U8G_COM_ST7920_SW_SPI
Definition: u8glib_ex.h:825
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
#define U8G_ATOMIC_END()
Definition: u8glib_ex.h:260
u8g_dev_t u8g_dev_uc1701_mini12864_hw_spi
Definition: u8glib_ex.h:378
u8g_dev_t u8g_dev_uc1601_c128032_2x_sw_spi
uint8_t u8g_com_arduino_hw_usart_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi
u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:3947
uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
#define U8G_COM_MSG_WRITE_SEQ_P
Definition: u8glib_ex.h:719
void u8g_EnableCursor(u8g_t *u8g)
#define U8G_PI_D4
Definition: u8glib_ex.h:1090
u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_parallel
u8g_dev_arg_pixel_t arg_pixel
Definition: u8glib_ex.h:1139
u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_sw_spi
void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
Definition: u8glib_ex.h:5669
static void u8g_font_calc_str_min_box(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
Definition: u8glib_ex.h:4313
#define U8G_MODE_R3G3B2
Definition: u8glib_ex.h:686
void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE
Definition: u8glib_ex.h:6567
u8g_dev_t u8g_dev_sdl_8bit
u8g_dev_t u8g_dev_st7920_128x64_custom
u8g_dev_t u8g_dev_uc1701_dogs102_hw_spi
Definition: u8glib_ex.h:371
u8g_dev_t u8g_dev_pcf8812_96x65_sw_spi
uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
Definition: u8glib_ex.h:5907
uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
Definition: u8glib_ex.h:5653
void u8g_pb8v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:8575
u8g_dev_t u8g_dev_st7920_202x32_8bit
void chess_Init(u8g_t *u8g, uint8_t empty_body_color)
static uint8_t u8g_font_GetBBXHeight(const void *font)
Definition: u8glib_ex.h:3178
u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_hw_spi
Definition: u8glib_ex.h:9882
#define U8G_NOCOMMON
Definition: u8glib_ex.h:216
#define U8G_PI_A0_STATE
Definition: u8glib_ex.h:1071
uint8_t u8g_pb8v1_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
u8g_dev_t u8g_dev_stdout
u8g_dev_t u8g_dev_t6963_240x64_8bit
uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
uint16_t u8g_font_GetEncoding65Pos(const void *font) U8G_NOINLINE
Definition: u8glib_ex.h:3199
u8g_uint_t height
Definition: u8glib_ex.h:1113
void u8g_pb8v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
Definition: u8glib_ex.h:8596
u8g_dev_t u8g_dev_t6963_240x128_8bit
void u8g_i2c_init(uint8_t options) U8G_NOINLINE
Definition: u8glib_ex.h:8463
uint8_t cursor_fg_color
Definition: u8glib_ex.h:1119
u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:4266
#define U8G_PI_I2C_OPTION
Definition: u8glib_ex.h:1092
int8_t u8g_draw_glyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3714
void u8g_MicroDelay(void)
Definition: u8glib_ex.h:6228
Definition: u8glib_ex.h:937
#define U8G_STATE_MSG_RESTORE_U8G
Definition: u8glib_ex.h:1224
#define U8G_DEV_MSG_CONTRAST
Definition: u8glib_ex.h:644
u8g_dev_t u8g_dev_st7565_nhd_c12832_parallel
int8_t font_ref_ascent
Definition: u8glib_ex.h:1134
void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
Definition: u8glib_ex.h:5118
u8g_dev_t u8g_dev_st7565_dogm128_2x_sw_spi
u8g_uint_t w
Definition: u8glib_ex.h:622
void u8g_SetScale2x2(u8g_t *u8g)
#define U8G_FONT_HEIGHT_MODE_TEXT
Definition: u8glib_ex.h:1106
#define U8G_ATOMIC_START()
Definition: u8glib_ex.h:259
#define U8G_COM_MSG_RESET
Definition: u8glib_ex.h:715
uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2978
u8g_dev_t u8g_dev_vs
u8g_dev_t u8g_dev_st7920_192x32_8bit
void u8g_pb16v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
Definition: u8glib_ex.h:8796
u8g_uint_t x0
Definition: u8glib_ex.h:628
void u8g_UndoRotation(u8g_t *u8g)
Definition: u8glib_ex.h:10367
uint8_t u8g_dev_ssd1306_adafruit_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2878
u8g_dev_t u8g_dev_uc1701_dogs102_2x_hw_spi
Definition: u8glib_ex.h:374
#define U8G_ALWAYS_INLINE
Definition: u8glib_ex.h:4691
u8g_state_cb state_cb
Definition: u8glib_ex.h:1146
static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE
Definition: u8glib_ex.h:3156
static uint8_t u8g_i2c_err_pos
Definition: u8glib_ex.h:7896
#define WRITE(IO, v)
Write to a pin wrapper.
Definition: fastio.h:48
void u8g_UpdateDimension(u8g_t *u8g)
Definition: u8glib_ex.h:5404
uint8_t font_line_spacing_factor
Definition: u8glib_ex.h:1136
u8g_dev_t u8g_dev_st7920_128x64_sw_spi
uint8_t pixel
Definition: u8glib_ex.h:609
#define U8G_DEV_MSG_SET_8PIXEL
Definition: u8glib_ex.h:669
uint8_t u8g_i2c_get_error(void) U8G_NOINLINE
Definition: u8glib_ex.h:7905
u8g_uint_t x
Definition: u8glib_ex.h:622
uint8_t u8g_com_arduino_ATtiny85_std_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
u8g_uint_t x1
Definition: u8glib_ex.h:628
void u8g_SetFontPosCenter(u8g_t *u8g)
Definition: u8glib_ex.h:4132
u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_hw_spi
u8g_pb_t u8g_dev_uc1701_mini12864_2x_pb
Definition: u8glib_ex.h:10899
u8g_box_t current_page
Definition: u8glib_ex.h:1148
u8g_dev_t u8g_dev_st7565_dogm132_sw_spi
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi
void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) U8G_NOINLINE
Definition: u8glib_ex.h:7510
#define u8g_GetMode(u8g)
Definition: u8glib_ex.h:1209
uint8_t u8g_font_GetFontEndEncoding(const void *font) U8G_NOINLINE
Definition: u8glib_ex.h:3215
u8g_dev_t u8g_dev_ssd1306_128x32_sw_spi
#define U8G_I2C_ERR_TIMEOUT
Definition: u8glib_ex.h:1423
#define U8G_DEV_MSG_GET_WIDTH
Definition: u8glib_ex.h:675
u8g_uint_t total_height
Definition: u8glib_ex.h:940
#define QWIDTH
Definition: u8glib_ex.h:2624
void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t *const arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:8564
void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE
uint8_t font_height_mode
Definition: u8glib_ex.h:1133
u8g_dev_t u8g_dev_pcd8544_84x48_hw_spi
int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3656
u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
Definition: u8glib_ex.h:3893
void chess_Step(uint8_t keycode)
int8_t u8g_font_GetLowerGDescent(const void *font)
Definition: u8glib_ex.h:3220
Definition: u8glib_ex.h:4304
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
uint8_t u8g_dev_st7565_nhd_c12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:9789
uint8_t u8g_font_GetFontStartEncoding(const void *font) U8G_NOINLINE
Definition: u8glib_ex.h:3210
#define U8G_COM_FAST_PARALLEL
Definition: u8glib_ex.h:849
u8g_pb_t u8g_dev_st7920_128x64_4x_pb
Definition: u8glib_ex.h:2626
void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
u8g_uint_t y0
Definition: u8glib_ex.h:628
#define U8G_MODE_GRAY2BIT
Definition: u8glib_ex.h:685
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
Definition: u8glib_ex.h:4768
u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_hw_spi
u8g_dev_t u8g_dev_st7565_lm6063_2x_sw_spi
#define U8G_DEV_MSG_SLEEP_ON
Definition: u8glib_ex.h:646
u8g_dev_t * dev
Definition: u8glib_ex.h:1116
void u8g_SetRot90(u8g_t *u8g)
Definition: u8glib_ex.h:10375
u8g_dev_t u8g_dev_ssd1327_96x96_gr_i2c
#define U8G_ESC_CS(x)
Definition: u8glib_ex.h:895
u8g_dev_t u8g_dev_st7920_128x64_4x_8bit
Definition: u8glib_ex.h:2629
u8g_dev_t u8g_dev_st7565_nhd_c12864_hw_spi
size_t u8g_font_GetSize(const void *font)
Definition: u8glib_ex.h:3253
uint8_t u8g_Begin(u8g_t *u8g)
Definition: u8glib_ex.h:5444
uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
uint8_t u8g_pb8v1_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
u8g_dev_t u8g_dev_st7565_dogm128_2x_parallel
void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:6619
void u8g_i2c_clear_error(void) U8G_NOINLINE
Definition: u8glib_ex.h:7899
int8_t u8g_DrawAAGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:4520
u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s)
Definition: u8glib_ex.h:4240
uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
Definition: u8glib_ex.h:5876
int8_t y_max
Definition: u8glib_ex.h:4307
void u8g_page_First(u8g_page_t *p) U8G_NOINLINE
Definition: u8glib_ex.h:4600
void u8g_pb16v1_Clear(u8g_pb_t *b)
Definition: u8glib_ex.h:8719
void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level)
void u8g_DisableCursor(u8g_t *u8g)
#define U8G_PI_SCK
Definition: u8glib_ex.h:1076
uint8_t color
Definition: u8glib_ex.h:611
u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_sw_spi
u8g_dev_t u8g_dev_sdl_1bit
#define U8G_DEV_MSG_SET_4TPIXEL
Definition: u8glib_ex.h:666
u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_usart_spi
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi
u8g_dev_t u8g_dev_st7920_192x32_4x_8bit
uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5881
u8g_dev_t u8g_dev_st7920_202x32_4x_8bit
#define U8G_DEV_MSG_INIT
Definition: u8glib_ex.h:640
uint8_t u8g_dev_st7565_nhd_c12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:9831
int8_t u8g_draw_glyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3662
#define SET_OUTPUT(IO)
set pin as output wrapper
Definition: fastio.h:56
u8g_dev_t u8g_dev_st7565_64128n_hw_spi
void(* u8g_state_cb)(uint8_t msg)
Definition: u8glib_ex.h:1054
u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_hw_spi
u8g_dev_t u8g_dev_pcd8544_84x48_sw_spi
uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn)
Definition: u8glib_ex.h:5467
u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb
Definition: u8glib_ex.h:3028
void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE
Definition: u8glib_ex.h:8542
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi
static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE
Definition: u8glib_ex.h:3162
void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:8775
int8_t glyph_dx
Definition: u8glib_ex.h:1126
uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
Definition: u8glib_ex.h:5773
int8_t u8g_font_GetFontAscent(const void *font)
Definition: u8glib_ex.h:3225
uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2569
#define U8G_DEV_MSG_GET_MODE
Definition: u8glib_ex.h:677
uint8_t u8g_pgm_uint8_t
Definition: u8glib_ex.h:240
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi)
#define U8G_I2C_ERR_BUS
Definition: u8glib_ex.h:1424
u8g_dev_t u8g_dev_ssd1351_128x128_332_hw_spi
uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10408
#define U8G_PI_EN
Definition: u8glib_ex.h:1074
uint8_t page
Definition: u8glib_ex.h:943
int8_t u8g_GetFontBBXOffX(u8g_t *u8g)
Definition: u8glib_ex.h:3304
u8g_dev_t u8g_dev_uc1701_dogs102_2x_sw_spi
Definition: u8glib_ex.h:373
u8g_dev_t u8g_dev_lc7981_320x64_8bit
u8g_dev_t u8g_dev_t6963_128x64_8bit
void st_Step(uint8_t player_pos, uint8_t is_auto_fire, uint8_t is_fire)
u8g_dev_t u8g_dev_ssd1306_128x32_2x_sw_spi
uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time)
Definition: u8glib_ex.h:5865
u8g_dev_t u8g_dev_ssd1351_128x128gh_332_sw_spi
u8g_dev_t u8g_dev_st7920_192x32_sw_spi
int8_t glyph_x
Definition: u8glib_ex.h:1127
uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
Definition: u8glib_ex.h:7375
#define U8G_PI_CS
Definition: u8glib_ex.h:1067
u8g_dev_t u8g_dev_st7920_128x64_8bit
uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
Definition: u8glib_ex.h:5897
u8g_dev_t u8g_dev_gprof
#define U8G_DRAW_LOWER_RIGHT
Definition: u8glib_ex.h:1371
int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3610
uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:9153
int8_t u8g_font_GetFontXAscent(const void *font)
Definition: u8glib_ex.h:3235
void u8g_font_box_min(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
Definition: u8glib_ex.h:4389
uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:9229
void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
Definition: u8glib_ex.h:5892
uint16_t u8g_font_GetEncoding97Pos(const void *font) U8G_NOINLINE
Definition: u8glib_ex.h:3205
#define U8G_COM_MSG_ADDRESS
Definition: u8glib_ex.h:710
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi
u8g_dev_t u8g_dev_uc1701_dogs102_sw_spi
Definition: u8glib_ex.h:370
void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t *const arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:6608
void u8g_SetFontRefHeightText(u8g_t *u8g)
Definition: u8glib_ex.h:4049
u8g_dev_t u8g_dev_st7565_64128n_2x_hw_spi
void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5870
#define U8G_DEV_MSG_SET_TPIXEL
Definition: u8glib_ex.h:665
u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi
Definition: u8glib_ex.h:3029
uint8_t u8g_AddToVirtualScreen(u8g_t *vs_u8g, u8g_uint_t x, u8g_uint_t y, u8g_t *child_u8g)
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
void u8g_SetPinInput(uint8_t internal_pin_number)
int8_t font_ref_descent
Definition: u8glib_ex.h:1135
u8g_uint_t cursor_y
Definition: u8glib_ex.h:1123
u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_hw_spi
u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi
u8g_dev_t u8g_dev_ssd1351_128x128gh_332_hw_spi
u8g_dev_t u8g_dev_st7565_nhd_c12832_sw_spi
uint8_t u8g_NextPage(u8g_t *u8g)
Definition: u8glib_ex.h:5644
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
Definition: u8glib_ex.h:4006
void u8g_SleepOff(u8g_t *u8g)
Definition: u8glib_ex.h:5663
#define U8G_MODE_HICOLOR
Definition: u8glib_ex.h:689
int8_t u8g_draw_glyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3766
uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10825
void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font)
void u8g_SetRot270(u8g_t *u8g)
Definition: u8glib_ex.h:10397
u8g_dev_t u8g_dev_lc7981_160x80_8bit
#define U8G_ESC_RST(x)
Definition: u8glib_ex.h:897
#define U8G_PI_D5
Definition: u8glib_ex.h:1091
void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
Definition: u8glib_ex.h:5240
void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
Definition: u8glib_ex.h:7583
void u8g_SetDefaultMidColor(u8g_t *u8g)
Definition: u8glib_ex.h:5822
u8g_page_t p
Definition: u8glib_ex.h:956
u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi
void u8g_font_box_all_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
Definition: u8glib_ex.h:4401
#define U8G_MODE_BW
Definition: u8glib_ex.h:684
u8g_com_fnptr com_fn
Definition: u8glib_ex.h:323
#define U8G_SPI_CLK_CYCLE_NONE
Definition: u8glib_ex.h:878
uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2521
Definition: u8glib_ex.h:1110
uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
void u8g_state_dummy_cb(uint8_t msg)
Definition: u8glib_ex.h:6288
void u8g_SetFontPosBottom(u8g_t *u8g)
Definition: u8glib_ex.h:4097
#define U8G_DEV_MSG_GET_PAGE_BOX
Definition: u8glib_ex.h:657
void u8g_UndoScale(u8g_t *u8g)
#define U8G_DEV_MSG_SLEEP_OFF
Definition: u8glib_ex.h:647
uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10507
const u8g_pgm_uint8_t * font
Definition: u8glib_ex.h:1117
void u8g_draw_hline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
Definition: u8glib_ex.h:7441
u8g_dev_t u8g_dev_ssd1351_128x128_idx_hw_spi
u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi
int8_t u8g_int_t
Definition: u8glib_ex.h:288
#define U8G_STATE_MSG_IS_BACKUP(msg)
Definition: u8glib_ex.h:1228
u8g_dev_t u8g_dev_st7565_lm6063_2x_hw_spi
const char * u8g_u8toa(uint8_t v, uint8_t d)
u8g_dev_t u8g_dev_ssd1327_96x96_gr_sw_spi
void chess_Draw(void)
#define U8G_PI_MOSI
Definition: u8glib_ex.h:1083
uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
u8g_dev_t u8g_dev_st7565_64128n_2x_sw_spi
u8g_dev_t u8g_dev_st7565_lm6059_2x_hw_spi
void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
Definition: u8glib_ex.h:4426
int u8g_sdl_get_key(void)
uint8_t(* u8g_dev_fnptr)(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:311
static uint8_t u8g_font_GetBBXWidth(const void *font)
Definition: u8glib_ex.h:3173
u8g_dev_t u8g_dev_uc1601_c128032_2x_hw_spi
#define U8G_FONT_DATA_STRUCT_SIZE
Definition: u8glib_ex.h:3092
const char * u8g_u16toa(uint16_t v, uint8_t d)
#define U8G_PI_CS1
Definition: u8glib_ex.h:1068
uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5305
void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
Definition: u8glib_ex.h:7521
u8g_dev_t u8g_dev_ssd1309_128x64_hw_spi
static void u8g_FillEmptyGlyphCache(u8g_t *u8g)
Definition: u8glib_ex.h:3383
void u8g_Delay(uint16_t val)
Definition: u8glib_ex.h:6224
#define U8G_PI_RW
Definition: u8glib_ex.h:1098
u8g_dev_t u8g_dev_uc1701_mini12864_2x_sw_spi
Definition: u8glib_ex.h:380
#define U8G_DRAW_UPPER_RIGHT
Definition: u8glib_ex.h:1368
u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
Definition: u8glib_ex.h:3839
uint8_t u8g_com_arduino_st7920_custom_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
void u8g_font_GetStrSize(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height)
u8g_uint_t page_height
Definition: u8glib_ex.h:939
u8g_dev_t u8g_dev_st7565_nhd_c12864_sw_spi
#define U8G_COM_MSG_WRITE_SEQ
Definition: u8glib_ex.h:718
u8g_draw_cursor_fn cursor_fn
Definition: u8glib_ex.h:1124
static void u8g_init_data(u8g_t *u8g)
Definition: u8glib_ex.h:5413
#define U8G_DRAW_UPPER_LEFT
Definition: u8glib_ex.h:1369
u8g_uint_t y
Definition: u8glib_ex.h:608
static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset)
Definition: u8glib_ex.h:3134
u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_sw_spi
void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
Definition: u8glib_ex.h:5129
int8_t x
Definition: u8glib_ex.h:4308
u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi
Definition: u8glib_ex.h:3030
int8_t u8g_font_GetFontDescent(const void *font)
Definition: u8glib_ex.h:3230
void(* u8g_draw_cursor_fn)(u8g_t *u8g)
Definition: u8glib_ex.h:1048
u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_hw_spi
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c
Definition: u8glib_ex.h:3042
uint8_t u8g_i2c_send_byte(uint8_t data) U8G_NOINLINE
Definition: u8glib_ex.h:8477
char(* u8g_font_get_char_fn)(const void *s)
Definition: u8glib_ex.h:4150
void u8g_SetFontRefHeightExtendedText(u8g_t *u8g)
Definition: u8glib_ex.h:4055
static uint8_t u8g_i2c_opt
Definition: u8glib_ex.h:7890
uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
Definition: u8glib_ex.h:7327
uint8_t blue
Definition: u8glib_ex.h:613
void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
Definition: u8glib_ex.h:7529
u8g_font_calc_vref_fnptr font_calc_vref
Definition: u8glib_ex.h:1132
u8g_dev_t u8g_dev_st7920_128x64_4x_custom
Definition: u8glib_ex.h:2630
void * dev_mem
Definition: u8glib_ex.h:322
uint8_t u8g_dev_uc1701_mini12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:10857
uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:7137
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_sw_spi
#define U8G_DEV_MSG_SET_XY_CB
Definition: u8glib_ex.h:673
Definition: u8glib_ex.h:620
u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c
Definition: u8glib_ex.h:3031
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE
Definition: u8glib_ex.h:8535
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi
u8g_dev_t u8g_dev_ht1632_24x16
void u8g_draw_vline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t h)
Definition: u8glib_ex.h:7459
#define U8G_STATE_MSG_RESTORE_ENV
Definition: u8glib_ex.h:1222
#define U8G_ESC_ADR(x)
Definition: u8glib_ex.h:896
uint8_t glyph_width
Definition: u8glib_ex.h:1129
u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi
int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:4231
int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3759
u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi
Definition: u8glib_ex.h:3041
u8g_dev_t u8g_dev_st7565_dogm128_parallel
Definition: u8glib_ex.h:626
int8_t u8g_font_GetFontXDescent(const void *font)
Definition: u8glib_ex.h:3240
void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb)
Definition: u8glib_ex.h:6293
void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
Definition: u8glib_ex.h:5343
#define U8G_PIN_NONE
Definition: u8glib_ex.h:1104
u8g_dev_t u8g_dev_ssd1327_96x96_gr_hw_spi
uint8_t u8g_GetFontBBXWidth(u8g_t *u8g)
Definition: u8glib_ex.h:3293
uint8_t mode
Definition: u8glib_ex.h:1121
static int8_t u8g_font_GetBBXOffY(const void *font)
Definition: u8glib_ex.h:3188
void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
Definition: u8glib_ex.h:5143
uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:8821
u8g_dev_t u8g_dev_ssd1351_128x128_idx_sw_spi
void u8g_SetFlipDiscCallback(u8g_t *u8g, void(*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2))
uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:7840
void u8g_font_box_left_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
Definition: u8glib_ex.h:4395
void u8g_font_GetStrMinBox(u8g_t *u8g, const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
uint8_t glyph_height
Definition: u8glib_ex.h:1130
u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:4220
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
char u8g_font_get_charP(const void *s)
Definition: u8glib_ex.h:4145
int8_t y
Definition: u8glib_ex.h:4308
#define U8G_FONT_HEIGHT_MODE_ALL
Definition: u8glib_ex.h:1108
void st_Draw(uint8_t fps)
static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE
Definition: u8glib_ex.h:3141
int8_t y_min
Definition: u8glib_ex.h:4306
u8g_dev_t u8g_dev_tls8204_84x48_sw_spi
u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g)
Definition: u8glib_ex.h:4080
uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
Definition: u8glib_ex.h:5809
Definition: u8glib_ex.h:319
static void u8g_font_get_str_box_fill_args(u8g_t *u8g, const char *s, u8g_str_size_t *buf, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
Definition: u8glib_ex.h:4407
u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
Definition: u8glib_ex.h:3859
int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3707
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel
void u8g_font_AdjustXYToDraw(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y)
void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE
Definition: u8glib_ex.h:8738
#define U8G_ESC_END
Definition: u8glib_ex.h:899
u8g_dev_t u8g_dev_sdl_fullcolor
u8g_uint_t page_y0
Definition: u8glib_ex.h:941
#define U8G_PIN_DUMMY
Definition: u8glib_ex.h:1103
uint8_t u8g_dev_ssd1306_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2941
u8g_uint_t u8g_font_calc_str_pixel_width(u8g_t *u8g, const char *s, u8g_font_get_char_fn get_char)
Definition: u8glib_ex.h:4153
void u8g_SetFontRefHeightAll(u8g_t *u8g)
Definition: u8glib_ex.h:4062
uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:9435
uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:10312
u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_parallel
u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_sw_spi
void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
Definition: u8glib_ex.h:7484
u8g_dev_t u8g_dev_st7920_128x64_hw_spi
uint8_t dir
Definition: u8glib_ex.h:610
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi
void u8g_EnableCom(u8g_t *u8g, u8g_dev_t *dev)
u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi
Definition: u8glib_ex.h:2628
uint8_t u8g_page_Next(u8g_page_t *p) U8G_NOINLINE
Definition: u8glib_ex.h:4608
u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5381
void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE
Definition: u8glib_ex.h:8731
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
uint8_t u8g_dev_sh1106_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2909
u8g_dev_t u8g_dev_ssd1309_128x64_i2c
void u8g_UpdateRefHeight(u8g_t *u8g)
Definition: u8glib_ex.h:4018
uint8_t u8g_uint_t
Definition: u8glib_ex.h:287
#define HEIGHT
Definition: u8glib_ex.h:10783
uint8_t cursor_encoding
Definition: u8glib_ex.h:1120
u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g)
Definition: u8glib_ex.h:4121
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c
void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
Definition: u8glib_ex.h:5708
#define U8G_PI_D3
Definition: u8glib_ex.h:1088
u8g_glyph_t u8g_GetGlyph(u8g_t *u8g, uint8_t requested_encoding)
Definition: u8glib_ex.h:3396
void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
Definition: u8glib_ex.h:7492
#define U8G_STATE_MSG_BACKUP_U8G
Definition: u8glib_ex.h:1225
u8g_uint_t idx
Definition: u8glib_ex.h:634
void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
Definition: u8glib_ex.h:5718
u8g_dev_t u8g_dev_lc7981_240x128_8bit
#define U8G_SPI_CLK_CYCLE_300NS
Definition: u8glib_ex.h:875
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
uint8_t u8g_dev_pb8v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
#define WIDTH
Definition: u8glib_ex.h:10782
u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_hw_spi
#define U8G_PI_CS2
Definition: u8glib_ex.h:1069
u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_hw_spi
int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding)
Definition: u8glib_ex.h:3473
#define U8G_DRAW_LOWER_LEFT
Definition: u8glib_ex.h:1370
void u8g_DrawCursor(u8g_t *u8g)
uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:5298
void u8g_DrawFilledEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
uint8_t(* u8g_com_fnptr)(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:314
#define U8G_ESC_DLY(x)
Definition: u8glib_ex.h:894
#define U8G_I2C_OPT_FAST
Definition: u8glib_ex.h:1416
u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_sw_spi
u8g_dev_t u8g_dev_st7920_202x32_sw_spi
u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
Definition: u8glib_ex.h:3926
#define U8G_COM_SW_SPI
Definition: u8glib_ex.h:824
u8g_dev_t u8g_dev_st7565_dogm128_2x_hw_spi
u8g_dev_t u8g_dev_a2_micro_printer_384x240
void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5886
u8g_dev_t u8g_dev_ssd1306_128x32_hw_spi
uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
u8g_dev_t u8g_dev_uc1701_mini12864_2x_hw_spi
Definition: u8glib_ex.h:381
u8g_dev_t u8g_dev_ssd1306_128x64_sw_spi
u8g_dev_t u8g_dev_uc1610_dogxl160_gr_sw_spi
u8g_uint_t h
Definition: u8glib_ex.h:622
#define U8G_COM_MSG_CHIP_SELECT
Definition: u8glib_ex.h:713
u8g_pb_t u8g_dev_sh1106_128x64_2x_pb
Definition: u8glib_ex.h:3039
void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor)
Definition: u8glib_ex.h:4069
void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y)
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi
void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
void u8g_FirstPage(u8g_t *u8g)
Definition: u8glib_ex.h:5639
uint8_t u8g_font_GetCapitalAHeight(const void *font)
Definition: u8glib_ex.h:3193
void u8g_font_AdjustXYToDrawP(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y)
void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
Definition: u8glib_ex.h:5679
void u8g_SetPinOutput(uint8_t internal_pin_number)
u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_sw_spi
uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:10726
uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
Definition: u8glib_ex.h:7301
uint8_t u8g_i2c_get_err_pos(void) U8G_NOINLINE
Definition: u8glib_ex.h:7910
#define U8G_FONT_SECTION(name)
Definition: u8glib_ex.h:221
uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
Definition: u8glib_ex.h:954
void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb)
Definition: u8glib_ex.h:5724
#define U8G_PB_DEV(name, width, height, page_height, dev_fn, com_fn)
Definition: u8glib_ex.h:985
void u8g_backup_spi(uint8_t msg)
Definition: u8glib_ex.h:6381
#define U8G_PI_WR
Definition: u8glib_ex.h:1097
#define U8G_STATE_MSG_BACKUP_ENV
Definition: u8glib_ex.h:1223
uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
Definition: u8glib_ex.h:5338
#define U8G_COM_MSG_STOP
Definition: u8glib_ex.h:707
void u8g_10MicroDelay(void)
Definition: u8glib_ex.h:6231
u8g_uint_t u8g_DrawAAStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
Definition: u8glib_ex.h:4526
#define U8G_PI_SET_A0
Definition: u8glib_ex.h:1089
#define U8G_DEV_MSG_PAGE_FIRST
Definition: u8glib_ex.h:649
const u8g_pgm_uint8_t * cursor_font
Definition: u8glib_ex.h:1118
uint8_t u8g_GetFontBBXHeight(u8g_t *u8g)
Definition: u8glib_ex.h:3298
#define U8G_SPI_CLK_CYCLE_50NS
Definition: u8glib_ex.h:874
#define U8G_PI_RD
Definition: u8glib_ex.h:1078
void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding)
u8g_dev_t u8g_dev_uc1610_dogxl160_bw_hw_spi
u8g_uint_t y1
Definition: u8glib_ex.h:628
static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
Definition: u8glib_ex.h:5214
void u8g_i2c_stop(void) U8G_NOINLINE
Definition: u8glib_ex.h:8482
#define U8G_PIN_LIST_LEN
Definition: u8glib_ex.h:1100
u8g_uint_t b
Definition: u8glib_ex.h:634
int8_t glyph_y
Definition: u8glib_ex.h:1128
u8g_dev_t u8g_dev_rot
Definition: u8glib_ex.h:10364
void u8g_SleepOn(u8g_t *u8g)
Definition: u8glib_ex.h:5658
u8g_uint_t(* u8g_font_calc_vref_fnptr)(u8g_t *u8g)
Definition: u8glib_ex.h:1051
uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
Definition: u8glib_ex.h:2847
void u8g_SetRot180(u8g_t *u8g)
Definition: u8glib_ex.h:10386
u8g_dev_t u8g_dev_sdl_2bit_double_mem
u8g_uint_t width
Definition: u8glib_ex.h:1112
u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_spi
Definition: u8glib_ex.h:632
uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:9679
void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg)
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi
void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
Definition: u8glib_ex.h:7365
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_hw_spi
void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
Definition: u8glib_ex.h:5361
u8g_uint_t cursor_x
Definition: u8glib_ex.h:1122
u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi
Definition: u8glib_ex.h:2627
u8g_dev_t u8g_dev_st7565_lm6063_hw_spi
#define U8G_PI_DI
Definition: u8glib_ex.h:1064
uint8_t u8g_pb8v1_IsYIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
u8g_dev_t u8g_dev_st7687_c144mvgd_8bit
int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
Definition: u8glib_ex.h:3813
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi
uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx)
Definition: u8glib_ex.h:7346
void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t *const arg_pixel) U8G_NOINLINE
Definition: u8glib_ex.h:8764
uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
static uint8_t U8G_ALWAYS_INLINE u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
Definition: u8glib_ex.h:4725
u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_sw_spi
uint8_t line_spacing
Definition: u8glib_ex.h:1137
u8g_uint_t w
Definition: u8glib_ex.h:4309
u8g_uint_t page_y1
Definition: u8glib_ex.h:942
#define U8G_PI_D1
Definition: u8glib_ex.h:1085
uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5454
void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
Definition: u8glib_ex.h:5351
u8g_dev_t u8g_dev_ks0108_128x64_fast
uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
Definition: u8glib_ex.h:5932
u8g_dev_t u8g_dev_uc1610_dogxl160_bw_sw_spi
#define U8G_COM_ST7920_HW_SPI
Definition: u8glib_ex.h:793
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi
#define U8G_COM_HW_SPI
Definition: u8glib_ex.h:792
u8g_dev_t u8g_dev_pbm_8h1
#define U8G_DEV_MSG_GET_HEIGHT
Definition: u8glib_ex.h:676
void u8g_SetDefaultForegroundColor(u8g_t *u8g)
Definition: u8glib_ex.h:5786
u8g_dev_t u8g_dev_uc1601_c128032_hw_spi
uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5324
void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2)
int8_t u8g_GetStrX(u8g_t *u8g, const char *s)
Definition: u8glib_ex.h:4225
uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
Definition: u8glib_ex.h:5071
uint8_t u8g_fntpgm_uint8_t
Definition: u8glib_ex.h:241
u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi
Definition: u8glib_ex.h:3040
void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5315
uint8_t u8g_Stop(u8g_t *u8g)
u8g_dev_t u8g_dev_pcf8812_96x65_hw_spi
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi
u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:5395
void u8g_arduino_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
Definition: u8glib_ex.h:4820
#define U8G_NOINLINE
Definition: u8glib_ex.h:214
void u8g_pb_Clear(u8g_pb_t *b)
Definition: u8glib_ex.h:7252
u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_sw_spi
u8g_pb_t u8g_dev_st7565_nhd_c12864_2x_pb
Definition: u8glib_ex.h:9880
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi
uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g)
Definition: u8glib_ex.h:5799
u8g_dev_t u8g_dev_ili9325d_320x240_8bit
uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
Definition: u8glib_ex.h:7398
void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
Definition: u8glib_ex.h:5154
uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
#define U8G_PI_RESET
Definition: u8glib_ex.h:1060
void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
Definition: u8glib_ex.h:7477
void * u8g_glyph_t
Definition: u8glib_ex.h:3089
void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
Definition: u8glib_ex.h:5745
u8g_dev_t u8g_dev_st7565_dogm128_sw_spi
u8g_uint_t x
Definition: u8glib_ex.h:608
u8g_dev_t u8g_dev_sdl_1bit_h
u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g)
Definition: u8glib_ex.h:4091
u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_parallel
uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
void u8g_pb8v1_Clear(u8g_pb_t *b) U8G_NOINLINE